简体   繁体   中英

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..

You've got the correct answer on your own. Just to err on the safer side, you should wait to receive an event before performing the transition or removing the object from the display list.

private function clip_touchBeginHandler(event:Event):void
{
    page1.addEventListener(Event.ADDED_TO_STAGE, page1_addedToStageHandler);
    addChild(page1);
}

private function page1_addedToStageHandler(event:Event):void
{
    var tm:TransitionManager = new TransitionManager(page1);
    var transition:Transition = tm.startTransition(...); // Add your transition parameters here
    transition.addEventListener("transitionInDone", transition_transitionInDone);
}

private function transition_transitionInDone(event:Event):void
{
    removeChild(page1);
}

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);
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM