AS3 to transition movie clips?

Posted on 2009-12-28
Last Modified: 2013-11-11
I have 4  movie clips that I want to play one after the other. I was hoping to have a simple transition between the movie clips. what is the best way to do this using AS3?
Question by:iDeej
    LVL 19

    Expert Comment

    assuming you want any particular movie clip to transition out at the last frame and load the new one, add the transition out code to the last frame of each one as well as a call to remove the current child (removeChild) and add the next one (addChild), then the transition in code.
    LVL 7

    Accepted Solution

    Create 4 movieclips on stage.

    Name them:

    THe in the timeline, create a actions layer and paste the following code:

    // import related libraries
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;
    // Create array to hold movieclips instances
    var clipsArray:Array = new Array();
    // Push the 4 movieclip instances to the array
    // Create a counter variable
    var clipCounter = 0;
    // Create a timer, set the timer to 1500 millisecond (1.5 seconds)
    var time:Timer = new Timer(1500, 1);
    // Add a listener to the timer (listens to when the timer is competed)
    time.addEventListener(TimerEvent.TIMER_COMPLETE, tweenAgain);
    // Create a tween object
    var myTween:Tween;
    // Initialize the function with the first movieclip ('0' index of the array
    // The main function to do the animation. The movieclip is passed as a parameter to this function
    function init(clip){
    	// THe line below does the tweening
    	var myTween:Tween = new Tween(clip, "x", Strong.easeIn, clip.x, clip.x+100, 2, true);
    	// LIne below increments the counter
    	// If the fourth movie clip has not been reached, that keep triggering the timer
    	if(clipCounter < clipsArray.length)
    		// This will start the timer
    // The timer callback function
    function tweenAgain(e:Event):void{

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
    In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now