A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Queue MovieClips

  1. #1
    Junior Member
    Join Date
    May 2005
    Location
    Australia
    Posts
    3

    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!

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    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!
    As ever,
    Vinayak Kadam

  3. #3
    Junior Member
    Join Date
    May 2005
    Location
    Australia
    Posts
    3
    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.

  4. #4
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    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 ?
    As ever,
    Vinayak Kadam

  5. #5
    Junior Member
    Join Date
    May 2005
    Location
    Australia
    Posts
    3
    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.

  6. #6
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    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();
    	}
    }
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center