Search code examples
apache-flexactionscripttween

how to apply tween motion on UIcomponents in flex using actionscript?


hello i want to apply tween motion on UIcomponents using actionscript in flex.

i searched alot but didn't find something useful help required.

thanks in advance.


Solution

  • The code below creates a move tween for a button in actionscript.

    Clicking anywhere on the screen will move the button to that location.

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" click="moveButton(event)">
    
        <mx:Script>
            <![CDATA[
                import mx.effects.Move;
    
                private function moveButton(event:MouseEvent):void {
                    var myMove:Move = new Move();
    
                    myMove.target = myButton;
                    myMove.xTo = event.stageX;
                    myMove.yTo = event.stageY;
                    myMove.play();
                }
            ]]>
        </mx:Script>
    
        <mx:Button id="myButton" />
    
    </mx:Application>
    

    For a more advanced example you could look at the Flex documentation: http://livedocs.adobe.com/flex/3/html/help.html?content=createeffects_3.html

    It shows an example how to extend and use the TweenEffect class to create your own effect class.