Using mxml transitions

Following script allows to expand and close a Flex component using a nice smooth transition
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="100"
styleName="container" currentState="closed">


<mx:Script>
<![CDATA[
import mx.effects.easing.Back;
import mx.effects.easing.Bounce;

private function onChangerClick( event:Event ) : void {

currentState = ( currentState == "open" ) ? "closed" : "open";

}
]]>
</mx:Script>




<!--STATES-->
<mx:states>
<mx:State name="open">
<mx:SetProperty name="height" value="450"/>
<mx:SetProperty target="{changeStatusButton}" name="label" value="Close"/>
</mx:State>

<mx:State name="closed">
<mx:SetProperty target="{this}" name="height"
value="100" />
</mx:State>
</mx:states>




<!--TRANSITIONS-->
<mx:transitions>

<!--Define the transition from 'open' to 'closed' state -->
<mx:Transition fromState="open" toState="closed">

<!--Parallel Transition-->
<mx:Parallel duration="500">

<!--Define RESIZE transition attributes specifing the target (the whole component)-->
<mx:Resize target="{this}"
easingFunction="{mx.effects.easing.Bounce.easeOut}"
duration="1500"/>
</mx:Parallel>

</mx:Transition>


<!--Define the transition from 'close' to 'open' state -->
<mx:Transition fromState="closed" toState="open">

<mx:Parallel duration="500">
<mx:Resize target="{this}"
easingFunction="{mx.effects.easing.Back.easeOut}"
duration="1000" />
</mx:Parallel>

</mx:Transition>
</mx:transitions>



<mx:Button id="changeStatusButton" label="Open"
click="onChangerClick(event);" />

</mx:VBox>

USING TWEENSY : particle runtime effects with Actionscript 3 and FLASH CS4

In the market are existing a lot of Tween libraries to help Flash/Flex developers to build cool actionscript animation making their life easier, like TweenLite/ TweenMaxor Caurina Tweener.
These libraries included cool stuff not provided from the default AS3 tween class like colors animation, animated drop, blur, shadow effect and much more.
So, in this post, i want to show you another tween engine, Tweensy, that provide a lot of cool bitmap and particle effects like smoke, fire and other 'magical'ÃÆââ‚Â
¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢âÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’Æâ€ââ
€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÃ
‚¢Ã¢â€šÂ¬ÃÂ
¢Ã¢â‚¬Å¾Ã‚¢ÃƒÆâ€
™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ãâ€
šÃ‚¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚¬Ãââ‚Â
¬Ã…¡Ãƒâ€šÃ‚ ÃƒÆ’ƒÂ
¢Ã¢âââ€Ã
…¡Ã‚¬Ã…¡Ã‚¬ÃÃ
ƒâ€šÃ‚¢ÃƒÂ¢Ã¢â€šÂ¬Ã…¾ÃÃÂ
¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãâââ€
šÂ¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã
ƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆâ€
™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’‚¢ÃÃ
ƒâ€šÃ‚¢ÃƒÂ¢Ã¢â€šÂ¬Ã…¡ÃÃÂ
¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¬ÃƒÆ’‚ÃâÃ
¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚ ÃƒÆ’Æ’Ãââ‚Â
¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃÆ
’ƒâ€šÃ‚¢ÃƒÆ’ÃÆâ€
™ÃƒÂ¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’¢âÃ
¢â‚¬Å¡Ã‚¬Ã…¡ÃÆâ€
™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¬ÃÃ
ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’†â€™Ãƒâ€šÃ‚¢ÃÆÃ
¢â‚¬â„¢ÃƒÆ’‚¢Ã¢â€šÂ¬ÃÆ
’ƒâ€¦Ã‚¾Ãƒâ€šÃÃ
†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’ÃÃ
ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€Ãâ
€šÃ‚ ÃƒÆ’¢â‚¬â„¢ÃÃâ
€ Ã¢â‚¬â„¢ÃƒÆ’†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã‚
 ÃƒÂ¢Ã¢â€ÅÂÂ
¡ÃƒÆ’‚¬Ã¢â€žÂ¢Ã
ƒÆ’Æâ€â„
¢ÃƒÆ’‚ÂÂÂÂ
¢ÃƒÆ’ĮբÃÆ
’ƒÆ’¢â‚Â
¬Ã…¡Ãâ€Ã
…¡Ãƒâ€šÃ‚¬ÃƒÆâ€â„
¢ÃƒÆ’¢â‚¬Å¡ÃƒÃÂ
¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚ ÃƒÃââ‚
¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆââ
‚¬â„¢ÃƒÆ’¢â‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢âÃ
¢â€šÂ¬Ã…¾Ã‚¢ÃƒÆ’ĉââ
€šÂ¬Ã…¡Ãƒâ€šÃÆ
’‚¢ÃƒÃÃ
¢â‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€Ãâ€
¦Ã‚¡ÃƒÆ’‚¢Ãƒ
¢âÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬
Å¡Ã
ƒÆ’ƒÆ’â€Ã
ƒÆ’…¡Ãƒâ€šÃ‚ÃÆ
’‚¬ÃƒÆ’Æâ
€™Ãƒâ€šÃâââ
€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãâ€Ã
…¡Ãƒâ€šÃ‚¢ÃƒÆ’¢ââââ‚
¬Å¡Ã‚¬Ã…¡Ã‚¬ÃÆâ€â„
¢ÃƒÆ’¢â‚¬Â¦Ãƒâ€šÃ‚¾ÃƒÃ
ƒÆ’†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã…¡Ã
ƒÆ’ƒâ€šÃ‚¢Ã
ƒÆ’Įâ€ââ
€žÂ¢ÃƒÆ’ƒâ€ Ã¢ââ€
šÂ¬Ã¢â€žÂ¢ÃƒÆ’Æ’Ã
ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÂÃ
ƒâ€šÃ‚¢ÃƒÆ’¢â€šÂ¬Ã¢Ã
¢â‚¬Å¾Ã‚¢ÃƒÆ’Ã
ƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’ÂÂÃ
‚¢ÃƒÆ’¢â€šÂ¬Ã‚ÃÆ
’‚ ÃƒÆ’ÂÃââ‚
¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’ƒÂ¢Ã¢â‚Â
¬Ã…¡Ã‚¬ÃÃâ€Å
¡Ãƒâ€šÃ‚¢ÃƒÆ’¢â‚¬Å¾Ãâ€
šÃ‚¢ÃƒÆ’ÆÃ
ƒÆ’¢â‚¬â„¢ÃƒÆ’†Ã
¢â‚¬â„¢ÃƒÃÃ
¢â‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃ‚¢ÃƒÃâ€Å
¡Ãƒâ€šÃ‚¢ÃƒÆ’¢â‚¬Å¡Ãâ€
šÃ‚¬Ãƒâ€¦Ãâ€Å
¡Ãƒâ€šÃ‚¡ÃƒÆ’ĮÃÆ
’¢â‚¬â„¢ÃƒÆ’¢âÃÃ
‚¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã…¡Ã
ƒÆ’â€Ãââ‚
¬Â¦Ãƒâ€šÃ‚¡ÃƒÆ’ƒâ€šÃ‚Ãâ€Å
¡Ãƒâ€šÃ‚¢ÃƒÆ’ƒÆ’Æââââ
‚¬Å¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢ÃÃ
‚¢Ã¢â‚¬Å¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’Æâââ€
šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃÆâ€â
„¢ÃƒÆ’‚¢Ã¢â€šÂ¬ÃÆâ€
™Ãƒâ€šÃ‚¢ÃƒÂ¢Ã¢â€šÂ¬Ã…¾Ã‚¢ÃƒÆâÃ
¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’ÃÆ
’‚¢Ã¢â€šÂ¬Ãâ
€¦Ã‚¡ÃƒÆ’â
€šÃâ€Ãâ
€¦Ã‚¡ÃƒÆ’‚¢ÃÆâ€â„Â
¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’ââââ
‚¬Å¡Ã‚¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢Ã
ƒÆ’ƒÆ’ƒâ€
šÃ‚ÂÃ
ƒâ€šÃ‚¢ÃƒÆ’ĮÃÂÂ
¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃââ
‚¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãâ€
šÃ‚¢ÃƒÂ¢Ã¢ââââ€
šÂ¬Ã…¡Ã‚¬Ã…¡Ã‚¬ÃÆâ€â
„¢ÃƒÆ’¢â‚¬Â¦Ãƒâ€šÃ‚¡Ãƒ
ƒâ€šÃ
ƒÆ’ƒÆ’‚¬ÃÆ
’ƒÆ’Įâ€âÃ
¢â‚¬Å¾Ã‚¢ÃƒÆ’ƒÂ¢Ã¢â€ÅÂ
¡Ãƒâ€šÃ‚¬Ãƒâ€šÃ‚¦ÃƒÆÃ
ƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã…¡ÃÃâ€
 Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¡ÃÆÃ
¢â‚¬â„¢ÃƒÆ’†â€™Ãƒâ€ Ã¢â‚¬â„¢Ã
ƒÆ’ƒâ€ Ã¢â‚ÂÂ
¬ÃƒÂ¢Ã¢â‚¬Å¾Ã‚¢ÃƒÆ’Æ’Ãââ
‚¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’¢ââÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã…¡Ã‚¬ÃÆÃ
¢â‚¬â„¢ÃƒÆ’¢â‚¬Â¦Ãƒâ€šÃ‚¡ÃÆââ
‚¬â„¢ÃƒÆ’†â€™Ãƒâ€ Ã¢â‚¬â„¢Ã
ƒÆ’¢â‚ÂÃ
ƒâ€šÃ‚¬ÃƒÆ’…¡ÃÆâ€ââ€
žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã…¡ÃƒÃÃ
‚¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¬ÃƒÃââ
‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆâ
€™ÃƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â
€žÂ¢ÃƒÆ’ĉâÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã‚ ÃƒÂ¢ÃÂÂÂ
¢ÃƒÆ’¢â‚¬Å¡Ã‚¬Ã¢â€ÅÃ
‚¾Ãƒâ€šÃ‚¢ÃƒÆ’ĮÃ
ƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃÃ
ƒÂ¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãââ
‚¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’¢ââÃÂ
¢Ã¢â‚¬Å¡Ã‚¬Ã…¡Ã‚¬Ã…¡ÃÆÃ
¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¬ÃÆââ
‚¬â„¢ÃƒÆ’†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã…Â
¡ÃƒÆ’‚ÂÂÂÂ
¦ÃƒÆ’ƒÆ’Æâ€
™Ãƒâ€ Ã¢ââÃ
¢â€šÂ¬Ã…¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’Æâ€â„
¢ÃƒÆ’‚¢Ã¢ÃÃâ
€šÃ‚¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚¬Ã…¡Ã‚ÂÂÂ
¬ÃƒÆ’ƒâ€¦Ã‚¡
ÃÆâ€Ã
¢â€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€Ãâ€
¦Ã‚¡Ãƒâ€šÃ‚¬Ãƒâ€¦Ã‚¡ÃƒÃâ€
 Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡ÃÃ
ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¡ stuff ;)



See the final result


SOURCE CODE:
To compile your flash file you'll need to download the Flash Cs4 source code (below) and get the right library assets.
Furthermore, you won't find the Tweensy API inside the zip file because you should download the last version from http://code.google.com/p/tweensy/.
Tweensy is still in beta and to create this sample(getting much more than inspiration from the provided demo) I used an old library version, so when you'll download the new one you could get some compiler errors.
package {
import flash.display.*;
import flash.events.*;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.text.TextField;
import flash.utils.getDefinitionByName;

import com.flashdynamix.motion.*;
import com.flashdynamix.motion.effects.*;
import com.flashdynamix.motion.extras.Emitter;
import com.flashdynamix.motion.layers.BitmapLayer;


public class MenuEmitter extends Sprite {


public var menuButton:MovieClip;

private var emittor : Emitter;
private var layer : BitmapLayer;

private var ct : ColorTransform;
private var bf : BlurFilter;

private var tx : Number;
private var ty : Number;

public function MenuEmitter() {


// Create a Bitmap Layer where we'll draw the Emitter and apply some effects
layer = new BitmapLayer(900, 400);
bf = new BlurFilter(10, 10, 2);
layer.add(new ColorEffect(new ColorTransform(1, 1, 1, 0.9)));
layer.add(new FilterEffect(bf));

// Set quality to LOW to get better performance
stage.quality = StageQuality.LOW;


// The Emitter MovieClip "BluePrint"
var Box : Class = getDefinitionByName("Box") as Class;

// Emitter Creation
ct = new ColorTransform(1, 1, 1, 1, -115, -30, 70);
emittor = new Emitter(Box, null, 2, 1, "0, 360", "1, 110", 1, BlendMode.ADD);
emittor.transform.colorTransform = ct;
emittor.endColor = {redOffset:255, greenOffset:-10, blueOffset:-270, alphaOffset:-255};

// We can't build the emitter on 0,0 because it will be cutted on the top and on the left side
emittor.x = 150
emittor.y = 150

// Display on screen
layer.draw(emittor.holder);
menuButton.addChildAt(layer,0);

// Stop emitter at startTime
emittor.stop()

// RollOver / RollOut on button
menuButton.gfx.buttonMode = true;
menuButton.gfx.addEventListener(MouseEvent.ROLL_OVER, onMenuRollOver)
menuButton.gfx.addEventListener(MouseEvent.ROLL_OUT, onMenuRollOut)

// ENTER_FRAME event
// We'll update the emittor properties to generate random
addEventListener(Event.ENTER_FRAME, update)

}

/**
* Update emittor rotation properties to have different rotation for each particle
*/
private function update(e : Event) : void {
emittor.rotation += 20;
}

/**
* At Button rollOver start the emitter
*/
private function onMenuRollOver(e : MouseEvent) : void {
emittor.start()
}

/**
* At Button rollOut stop the emitter
*/
private function onMenuRollOut(e : MouseEvent) : void {
emittor.stop()
}





}
}

Using 3D and Video with Caurina Tween in Flash Cs4

In this sample, full-commented, we'll use the FlashPlayer 10 3D features to display a list of Video Thumbnails enabling the Mouse Click Event to enlarge them changing their z and rotationY properties.
We'll use Caurina Tween to perform 3d animations, so download them and copy the caurina package in your project folder before test this sample (they are not included inside the source files)
IMPORTANT NOTE: 3D topic is really complex! This is only an introduction to this world and this VideoGallery needs a lot of improvements to be used in a real scenario.
To this URL the flash file with the final result (click on VideoThumbs to display 3D animations):


CREATE THE FLASH FILE

First of all we create a new Flash ActionScript 3.0 document (setting Flash Player 10 in the Publish Setting menu).
Create a new MovieClip with an FLVPlayBack component inside (with istance name videoFLB) and link the movieclip to the VideoThumb.as class.
See image below


// FLASH DOCUMENT CLASS
package {

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.MouseEvent;
import caurina.transitions.*
import flash.display.DisplayObject;

public class VideoMain extends Sprite
{

// Horizontal Gap between Video Thumbs
private const HORIZONTAL_GAP:uint = 50;

// Total of VideoThumbs to show
private const VIDEO_TOTAL:uint = 6;

// Thumbnails original Y position
private const Y_POS:uint = 125;

// Thumbnails original Z position
private const Z_POS:uint = 550;



public function VideoMain()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;


// Create video thumbs
for (var i:uint = 0; i < VIDEO_TOTAL; i++) {

// Create a new VideoThumb istance
var thumb:VideoThumb = new VideoThumb();

// Save original Index VideoThumb
thumb.originalIndex = i;

// Set Thumb Position (x, y, z)
thumb.x = thumb.originalX = HORIZONTAL_GAP * i
thumb.y = Y_POS
thumb.z = Z_POS;

// Set Thumb Rotation
thumb.rotationY = -90;

thumb.addEventListener(MouseEvent.CLICK, onClick)
thumb.buttonMode = true;

addChild(thumb)
}
}



/**
* Click Video MovieClip
*/
private function onClick(event:MouseEvent):void
{
// If clicked videoThumb is already opened
if(event.currentTarget.isOpened) {

// Back to the original position
Tweener.addTween(event.currentTarget, {
rotationY: -90 ,
x: event.currentTarget.originalX,
y: Y_POS,
z: Z_POS,
time:0.5,
transition:"easeInOutSine",
onComplete: event.currentTarget.videoFLB.stop()});


// Set depth to the original Position
this.swapChildrenAt(getChildIndex(event.currentTarget as DisplayObject), event.currentTarget.originalIndex)



} else {

// Enlarge Video and PLay it when animation is completed
Tweener.addTween(event.currentTarget, {
rotationY: 0 ,
x: 230,
y: 200,
z: 0,
rotationY: 0,
time:0.5,
transition:"easeInOutSine",
onComplete: event.currentTarget.videoFLB.play()});

// Bring to Front
this.swapChildrenAt(event.currentTarget.originalIndex, this.numChildren -1 )

}


// Change isOpened Status (to always know if a thumb is opened )
event.currentTarget.isOpened = !event.currentTarget.isOpened;

}


}
}





// VideoThumb.as Class
package {


import flash.display.MovieClip;


public class VideoThumb extends MovieClip
{

private var _originalIndex:Number ;
private var _originalX:Number ;
private var _isOpened:Boolean = false;


/**
* Constructor
*/
public function VideoThumb(){}


/**
* Original Index position (usefull to know the Thumb depth)
*/
public function set originalIndex(val:Number):void {
_originalIndex = val;
}

public function get originalX():Number {
return _originalX ;
}




/**
* Original x position (usefull to position Thumb to the original Position)
*/
public function set originalX(val:Number):void {
_originalX = val;
}


public function get originalIndex():Number {
return _originalIndex ;
}




/**
* If the VideoThumb is opened or not
*/
public function set isOpened(val:Boolean):void {
_isOpened = val;
}


public function get isOpened():Boolean {
return _isOpened ;
}


}
}