Ultrashock Forums > Flash > ActionScript
AS2 - playing swf in a sequence
Member Blogs
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
AS2 - playing swf in a sequence
Old 2008-07-18

Hi,
Would anyone have an idea where can I find a tutorial that explains how to play multiple swf files sequentially, just like in a slideshow.
Thank you
postbit arrow 4 comments | 264 views postbit arrow Reply: with Quote   
uxk8396
Registered User
uxk8396 is offline
seperator
Posts: 55
2004-11-16
seperator

Ultrashock Member Comments:
Gregaz81's Avatar Gregaz81 Gregaz81 is offline Gregaz81 lives in Sweden 3 Blog Entries 2008-07-19 #2 Old  
say you´re loading your swf´s into a mc called "container"

this code puts four swf´s in an array and load the first swf, then when current swf
reaches it´s last frame, the next swf loads.

ActionScript Code:
  1. var _currentMovieNum:Number = 0;
  2. var _movies:Array = ["first.swf", "second.swf", "third.swf", "fourth.swf"];
  3.  
  4. var mcl:MovieClipLoader = new MovieClipLoader();
  5. var list:Object = new Obejct();
  6. mcl.addListener(list);
  7.  
  8. list.onLoadInit(mc:MovieClip){
  9.     trace("current swf is: " + _movies[_currentMovieNum])
  10. }
  11.  
  12. mcl.loadClip(_movies[_currentMovieNum], container);
  13.  
  14. /// use an onEnterFrame function to keep track of the timeline of your swf´s
  15. this.onEnterFrame = function(){
  16.     if(_currentMovieNum != _movies.length-1){
  17.         if(container._currentFrame == container._totalFrames){
  18.             _currentMovieNum ++
  19.             mcl.loadClip(_movies[_currentMovieNum], container);
  20.         }
  21.     } else {
  22.         _currentMovieNum = 0;
  23.         mcl.loadClip(_movies[_currentMovieNum], container);
  24.     }
  25. }

is this what you´re looking for?
Let me know how it turns out for you
Reply With Quote  
uxk8396 uxk8396 is offline 2008-07-21 #3 Old  
Hi,
It seems that this line should include a "function"
list.onLoadInit=function(mc:MovieClip){
I created a movie clip on stage called "mcl", and tested the file, but it did not work.
Can you please take a look again.
Thank you
Reply With Quote  
Gregaz81's Avatar Gregaz81 Gregaz81 is offline Gregaz81 lives in Sweden 3 Blog Entries 2008-07-22 #4 Old  
Hi again
the
ActionScript Code:
  1. list.onLoadInit = function(mc:MovieClip){
  2.    trace("current swf is: " + _movies[_currentMovieNum])
  3. }
is a function of the MovieClipLoader-class, the "init" means that the file you´re loading through mcl.loadClip is complete.

The things you have to do to get this to work:
- rename the "mcl"-movieclip to "container" without the "" ofcourse.
- create 4 swf´s and name them first.swf, second.swf and so on ( or change the names in the array at the top to the actual names of your sequence-swf´s)

that´s about it

Let me know if you get this to work...
Reply With Quote  
Gregaz81's Avatar Gregaz81 Gregaz81 is offline Gregaz81 lives in Sweden 3 Blog Entries 2008-07-22 #5 Old  
I just wanna point out that you should rename your movieclip "mcl" ON STAGE to "container", don´t change anything in the code, mcl should remain mcl in the code.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: