-
Queue MovieClips
Hi there,
I am trying to programmatically queue MovieClips on the scene to play one after the other. I have tried onEnterFrame with Event.ENTER_FRAME that gotoAndStop() to next fram each time, but this does not show the MovieClip playing somewhy.
Is there a way to programmatically link (in AS3) MovieClips to play one after the other? One I tried is at http://stackoverflow.com/questions/1...ngle-movieclip and I have tried creating actionscript at last frame for each movieclip, but this goes directly into function I specify as an event at the time of creation (MovieClip.addFrameScript(MovieClip.totalFrames - 1, MyEventFunction) )
Thanks!
-
Senior Member
I am sorry but your description is not so helpful for us to suggest you alternatives. It would be great if you cud attach your source files here so that we can look into them and suggest a solution. That will speed up the process!
-
What I am trying to do is as follows. Consider that I have an array of MovieClips that I wish to play one after another:
var Movies:Array = [Movie1, Movie2, Movie3, Movie4];
But before I can play Movie1, I need to link these movies, so that when Movie1 reaches last frame, it starts playing Movie2, and so forth. I tried it the following way:
var iCurrentIndex:Number = 0;
Movie1.onEnterFrame = null;
Movie1.onEnterFrame = function() { OnFrame(); };
function OnFrame():void
{
if(iCurrentIndex == Movies.length) // Replay last movie over and over
iCurrentIndex = Movies.length - 1;
var Movie:Object = Movies[iCurrentIndex];
trace("Playing frame #" + Movie.currentFrame + " of movie \"" + Movie.name + "\"");
if(Movie.currentFrame == 1) // If new movie started playing, reset it and make sure it has reference to this function
{
Movie.onEnterFrame = null;
Movie.onEnterFrame = function() {OnFrame(); };
Movie.play();
}
else
{
if(Movie.currentFrame == Movie.totalFrames) // Movie finished playing, go to next one
{
// Reset onEnterFrame for played movie
Movie.onEnterFrame = null;
iCurrentIndex++;
OnFrame();
return;
}
}
}
For some reason, onEnterFrame does not register throughout function() {OnFrame();} assignation, not sure why even though Movie1 keeps playing on scene.
-
Senior Member
Is it possible for you to upload your FLA here.....I can definetly copy your code and create one FLA for me but if thats the case then why not use your own FLA ?
-
No, its not really possible as it is not mine. You can create two simplest animations of 10 frames each and try playing them one after another after instancing them on the scene. Code I have given does not work if pasted directly into scene. I am trying to figure out why.
-
Flashmatics
create two movie clips movie0, movie1 with animations in them... (dont put any stop actions in them).
Then try the following code:
Code:
var aMovies:Array = [movie0, movie1];
var currIndex:Number = 0;
//first stop all movieclips
for(var i:Number = 0; i < aMovies.length; i++)
{
aMovies[i].stop();
}
//now start the cycle
startMovie();
function startMovie()
{
if(currIndex == aMovies.length) currIndex = 0;
aMovies[currIndex].gotoAndPlay(1);
aMovies[currIndex].onEnterFrame = playStuff;
}
function playStuff()
{
if(this._currentframe == this._totalframes)
{
this.stop();
delete this.onEnterFrame;
currIndex++;
startMovie();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|