?
Solved

AS3 to transition movie clips?

Posted on 2009-12-28
2
Medium Priority
?
578 Views
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?
0
Comment
Question by:iDeej
2 Comments
 
LVL 19

Expert Comment

by:moagrius
ID: 26135458
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.
0
 
LVL 7

Accepted Solution

by:
ssdesign earned 2000 total points
ID: 26136778
Create 4 movieclips on stage.

Name them:
mc1
mc2
mc3
mc4

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
clipsArray.push(MovieClip(mc1));
clipsArray.push(MovieClip(mc2));
clipsArray.push(MovieClip(mc3));
clipsArray.push(MovieClip(mc4));

// 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
init(clipsArray[0]);

// 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
	clipCounter++;
	// If the fourth movie clip has not been reached, that keep triggering the timer
	if(clipCounter < clipsArray.length)
	{
		// This will start the timer
		time.start();
	}
	
}
// The timer callback function
function tweenAgain(e:Event):void{
	trace("complete");
	time.stop();
	init(clipsArray[clipCounter]);
}

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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