Search code examples
actionscript-3transitioneffecttweenaddchild

addchild with animate cc by Actionscript 3 language


How to with "addchild(page2)" animate showing with Tweening!

This is my simple class of actionscript to make that,MovieClip did not play animation when using addChild(), do you have any suggestions?

my page1..3 are MovieClips!

package
{

    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.TouchEvent;

    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

    public class Main extends MovieClip
    {
        var page1: Page1;
        var page2: Page2;
        var page3: Page3;


        public function Main()
        {
            page1 = new Page1;
            page2 = new Page2;
            page3 = new Page3;
            addChild(page1);
            //


            //
            page1.clip2.addEventListener(TouchEvent.TOUCH_BEGIN, onClip2ButtonClick);
            page2.clip.addEventListener(TouchEvent.TOUCH_BEGIN, onClipButtonClick);
        }

        function onClipButtonClick(event: TouchEvent): void
        {
            addChild(page3);
            removeChild(page2);
        }

        function onClip2ButtonClick(event: TouchEvent): void
        {
            addChild(page2);
            removeChild(page1);
        }

    }

}

We Can by this tween and without programming

by tweening motion with frames, we can use multi effect. In this file fade effect uses for that, but can 3d effect and another..


Solution

  • We try and got it. By add this code in our class.

    function onClipButtonClick(event: TouchEvent): void
                {
                    addChild(page1);
                    var myTM: TransitionManager = new TransitionManager(page1);
                    myTM.startTransition(
                    {
                        type: Fly,
                        direction: Transition.IN,
                        duration: 3,
                        easing: Back.easeOut
                    })
    
                    removeChild(page2);
                }