rss twitter

The finer Art of Loading (#2): It’s all about timing

Hey everyone,
in the last chapter we made it to load a SWF and unload it on demand. Let's continue here and imagine that we're having three SWFs, each of them having some content which should be shown on click. A typical usage would obviously be a Flash Website consisting of multiple SWFs.

What we're going to do:

At the end of this article we're having three SWFs loaded which can be displayed seperately on click. Sounds pretty trivial but takes some management as well. If you are just interested in that "loading and displaying" click here to scroll to the bottom.

Why is here so much text?

Much of this article doesn't really cover this single purpose but is more going into the general question of how to handle multiple loading-processes. I have seen many Flash projects with a cruel loading management which definetly leads into a "I don't like Flash" attitude. Knowing how to load data is something the HTML world doesn't really have to take care for but we do have and we should think about how to use this option. We can give the user the feeling of getting much content without waiting, we just have to check when it's time to load this.

Thoughts about storing data or always un- & reload it:

My experiences showed me that loading Flash data only on click is one of the most reasons people don't like flash. Why not using the time the user spent on the website to prepare the rest of the content? In 9 of 10 projects that left my table the customer wanted it like everyone's liking it: We're loading data and store it in the cache - just like any video streaming does and not "Why is there again and again a Preloader?" Of course this strongly depends on the project. It doesn't make sense to cache videos or a large amount of images if this would lower the overall performance. Leads me to the general question:

When to load content?

At the very first you have to decide whether to load every Data at once and after all loading processes are done start showing the content or loading just the first files, showing content pretty fast and then start loading the rest in the background while the user can already read content.

Loading the entire content is useful when dealing with a complete size of 2-3MB. The user has to wait in the beginning but then can be sure everything is loaded. I've to admit that I don't use this way too often, the reason is simple: You can do so in one SWF then as well and it makes the whole page work better together. Anyway, the good thing about using multiple SWFs is that you can easily update content without compiling the whole project again and besides working in a team on that is much easier.

Let's check the other option: Loading the first SWF (or the small-sized first, nevermind), adding it to stage and loading the rest in the background. This way can be pretty useful when having slightly bandwith-using content, e.g. a gallery. Does the user really have to wait for the gallery when he opens the site? He might be waiting for 20mb but the site is 1mb without the gallery. So loading it after the rest is absolutely necessary - but wouldn't it be annoying as well if the gallery would start loading only on click? You've then got to wait for it to completely load but you spent already some time on the website - so why not use this time to load the gallery in the background? I'd say this is a big advantage of Flash to load content the user will see. Imagine following: The user opens your website, waiting some seconds for the first content. Then he's spending 30 seconds on it - enough time for the gallery to complete loading. He clicks on gallery and there it is, on click and he didn't even had to wait.

Conclusion to that:

In most cases a mix of both is the right way. You're going to load all the small content elements, such as news, contact, whatever - and load the heavy data like portfolios, galleries, videos, ... at last. The user will not be disappointed when he's seing the gallery-preloader at 60% when clicking it at first but he will continue surfing on the rest of the page till the gallery is loaded. The best case would be that the gallery is completely loaded when the user clicks of course. You've got to find the way in between performance lowering because of caching too much and serving content on demand. Keep in mind that doing this kind of load-management requires some coding knowledge as you have to work with multiple loaders called by different times. But hang on, this will be the #3 on this article series.

Now finally back to the topic: Let's load some SWFs and display it on click.

Load multiple SWFs and store them

As said I'm going to cover the complexity of having different loading processes managed in the next chapter, so at first we're going to load every SWF in the beginning, storing them and show them when wanted. Let's declare some variables first.

Actionscript:
  1. var _swfPathArr:Array = new Array("00.swf", "01.swf", "02.swf");
  2. var _loadedSWFs:int;
  3.  
  4. var _swfClipsArr:Array = new Array();
  5. var _swfTempClip:MovieClip;

Pretty self-explaining I guess. The temporary MovieClip will be used to quickly store the data (mainly for reasons of adding additional things to it while defining. You'll see in a minute) Now we'll call the function which will start the whole process.

Actionscript:
  1. startLoading(_swfPathArr);
  2.  
  3. function startLoading(pathArr:Array):void {
  4.     _swfLoader = new Loader();
  5.     _swfRequest = new URLRequest();
  6.    
  7.     loadSWF(pathArr[0]);
  8. }
  9.  
  10. function loadSWF(path:String):void {
  11.     setupListeners(_swfLoader.contentLoaderInfo);
  12.    
  13.     _swfRequest.url = path;
  14.     _swfLoader.load(_swfRequest);
  15. }
  16.  
  17. function setupListeners(dispatcher:IEventDispatcher):void {
  18.     dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
  19.     dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
  20. }
  21.  
  22. function currentSwfProgress(event:ProgressEvent):void {
  23.     var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
  24.     // swfPreloader.percentTF.text = _perc + "%";
  25. }


Using just one Loader instance for all files:

You might have noticed yet that we've got only one Loader instance yet to load each SWF after another. This is because it's making much more sense in this case than loading all files at the same time with multiple loaders. You've got much more control about every loading process, it's easier to determine errors and the speed remains the same. Besides it's much easier to code.

But nevertheless there are cases in which you definetly should work with many instances, e.g. a gallery with many images. I'm going to get into that deeper in the next article as well.

Do the loop and storing
The loader shall continue loading the SWFs while the completely loaded are stored - until every SWF is stored and then the first SWF can be added to stage. The onSwfComplete function is called the first time after - you might know - the first SWF is completely loaded :)

Actionscript:
  1. function onSwfComplete(event:Event):void {
  2.     event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
  3.     event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
  4.  
  5.     _swfTempClip = event.target.content;
  6.     _swfTempClip.customID = _loadedSWF;
  7.  
  8.     _swfClipsArr.push(_swfTempClip);
  9.    
  10.     if(_loadedSWFs <_swfPathArr.length - 1) {
  11.         _loadedSWFs++;
  12.         loadSWF(_swfPathArr[_loadedSWFs]);
  13.     } else {
  14.         onCompletePreloading();
  15.     }
  16. }

We're removing the EventListener at first. Just to make sure, you know. Then we're setting the _swfTempClip to the SWF we've just successfully loaded and add an ID to it. Only to check if everything works fine later on. We're pushing it into our Array to store it - the temp clip will be overwritten the next time, but the already loaded one was pushed into our Array. Then the loop is triggered. If the count (which started at 0) is below the count of SWFs we wanna load, we're going to start the loading of the next swf. We're passing the new path as _count is now 1, therefore the second path is used. When every SWF is loaded the onPreloadComplete(); function is called.

Let's imagine we've got three buttons to show the different SWFs. We know for sure, that the first file we've declared in our _swfPathArray has got the Array-Index 0 in our _swfClipsArr. So we can easily access it with _swfClipsArr[0]. To make this really usable for the Flash IDE (don't throw stones on me loved FDT users :)) we're going to easily switch the button's name to load the correct SWF. Besides we've got a MovieClip called "contentContainer" on the stage (yea, the visual stage with a named MC in the Properties!) which holds the SWF.

Actionscript:
  1. function onCompletePreloading():void {
  2.     contentContainer.addChild(_swfClipsArr[0]);
  3.    
  4.     news_btn.addEventListener(MouseEvent.CLICK, setContent);
  5.     portfolio_btn.addEventListener(MouseEvent.CLICK, setContent);
  6.     contact_btn.addEventListener(MouseEvent.CLICK, setContent);
  7. }
  8.  
  9. function setContent(event:MouseEvent):void {
  10.     var _swfToAdd:MovieClip;
  11.    
  12.     switch(event.target.name) {
  13.         case "news_btn":
  14.         _swfToAdd = _swfClipsArr[0];
  15.         break;
  16.        
  17.         case "portfolio_btn":
  18.         _swfToAdd = _swfClipsArr[1];
  19.         break;
  20.        
  21.         case "contact_btn":
  22.         _swfToAdd = _swfClipsArr[2];
  23.         break;
  24.     }
  25.    
  26.     contentContainer.removeChildAt(contentContainer.numChildren-1);
  27.     contentContainer.addChild(_swfToAdd);
  28.     trace(_swfToAdd.customID);
  29. }

It's simple as that. We're removing the old SWF from the stage (by determing it to be the last Object added to the MC) and add the new one. The _swfClipsArr's index is equal to the _swfPathArr entries. The trace at the end shows that we're still having control of custom properties we gave our loaded SWFs.

The result:

You can easily test it yourself. Create three SWFs and one loading-SWF. Create three MCs (for the buttons) and an empty MC (as contentContainer) on the loading-SWF's stage. Name the MCs properly and copy the following snippet to your first frame. If you didn't know yet: Testing to display loaded files (from 1MB upwards) in Flash locally cause a lag while adding it to stage. But testing online gives the wanted result. The SWF is changed directly on click.

Here it is:

Actionscript:
  1. var _swfLoader:Loader;
  2. var _swfRequest:URLRequest;
  3.  
  4. var _swfPathArr:Array = new Array("00.swf", "01.swf", "02.swf");
  5.  
  6. var _swfClipsArr:Array = new Array();
  7. var _swfTempClip:MovieClip;
  8. var _loadedSWFs:int;
  9.  
  10.  
  11. startLoading(_swfPathArr);
  12.  
  13. function startLoading(pathArr:Array):void {
  14.     _swfLoader = new Loader();
  15.     _swfRequest = new URLRequest();
  16.    
  17.     loadSWF(pathArr[0]);
  18. }
  19.  
  20. function loadSWF(path:String):void {
  21.     setupListeners(_swfLoader.contentLoaderInfo);
  22.    
  23.     _swfRequest.url = path;
  24.     _swfLoader.load(_swfRequest);
  25. }
  26.  
  27. function setupListeners(dispatcher:IEventDispatcher):void {
  28.     dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
  29.     dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
  30. }
  31.  
  32. function currentSwfProgress(event:ProgressEvent):void {
  33.     var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
  34.     // swfPreloader.percentTF.text = _perc + "%";
  35. }
  36.  
  37.  
  38. function onSwfComplete(event:Event):void {
  39.     event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
  40.     event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
  41.  
  42.     _swfTempClip = event.target.content;
  43.     _swfTempClip.customID = _loadedSWFs;
  44.     _swfClipsArr.push(_swfTempClip);
  45.    
  46.     if(_loadedSWFs <_swfPathArr.length - 1) {
  47.         _loadedSWFs++;
  48.         loadSWF(_swfPathArr[_loadedSWFs]);
  49.     } else {
  50.         _swfLoader.unloadAndStop();
  51.         _swfLoader = null;
  52.         onCompletePreloading();
  53.     }
  54. }
  55.  
  56. function onCompletePreloading():void {
  57.     contentContainer.addChild(_swfClipsArr[0]);
  58.    
  59.     news_btn.addEventListener(MouseEvent.CLICK, setContent);
  60.     portfolio_btn.addEventListener(MouseEvent.CLICK, setContent);
  61.     contact_btn.addEventListener(MouseEvent.CLICK, setContent);
  62. }
  63.  
  64. function setContent(event:MouseEvent):void {
  65.     var _swfToAdd:MovieClip;
  66.    
  67.     switch(event.target.name) {
  68.         case "news_btn":
  69.         _swfToAdd = _swfClipsArr[0];
  70.         break;
  71.        
  72.         case "portfolio_btn":
  73.         _swfToAdd = _swfClipsArr[1];
  74.         break;
  75.        
  76.         case "contact_btn":
  77.         _swfToAdd = _swfClipsArr[2];
  78.         break;
  79.     }
  80.    
  81.     contentContainer.removeChildAt(contentContainer.numChildren-1);
  82.     contentContainer.addChild(_swfToAdd);
  83.     trace(_swfToAdd.customID);
  84. }

Please feel free to correct me and notice, that this snippet is simplified, e.g. IO_ERRORs must be listened, fallbacks must be defined, etc. I just wanted to keep the focus on loading, storing and adding multiple SWFs.

74 Responses to “The finer Art of Loading (#2): It’s all about timing”

  1. Raphael W. says:

    Hi Marvin,
    thank you so much for this article! Made me see some things clearer now and because I am going to work with loading stuff in future more often I will definetly follow your tips and think about everything before starting. Thanks again, also for your time to write such a detailed & rich article.

    Kind regards,
    Raphael.

  2. AS3 Student says:

    THANKS FOR THE HEADS UP MARVIN! Just checked the other post and read your quick note, and so I went to the root page on this site. wow this article is amazing. going to read over it ALL carefully. THANK YOU SIR for taking the time and writing such thorough explanations. you should have a PAYPAL DONATE button by the article. IM SERIOUS!

    THank you,
    AS3 Student.

  3. Stephan says:

    Would donate as well! :-D Seriously this was a lot of work which really helped me taking a deeper look at this topic. Many many thanks to you, Marvin!

  4. Joe Gerald says:

    thanks so much. i was searching so long for a solution to load multiple swfs from an array. this works like a charm!

  5. Marvin Blase says:

    hey, you're all welcome :) glad to help! stay tuned for part three which again will get deeper into loading processes, e.g. preloading images from an xml.

  6. [...] ≠ Musiker & Grafiker # Die beste Idee wird als Open Source Projekt umgesetzt! # The finer Art of Loading (#2) - It's all about timing! # Auf MovieClips & Funktionen von externen SWFs [...]

  7. Patrick Hill says:

    I tried the code and got an error 2035 message. I apparently have not properly specified the path to the .swf/s (to-be-loaded). All my .swf's are in the same directory.

    I look forward to understanding ALL this code and to using it. Thank you for help.

  8. Wicked tutorial! You are a genius! With clean code. You've made a lot of people incredibly happy.

    Heads up: If by the luck of the draw the child swf file that's being loaded into the parent swf happens to include some actionscript that consist of building components programmatically rather than dragging and dropping from the Components window, you might run into trouble. For example, in one of my child swfs, I'm programmatically loading a DataGrid object; in a second one, I'm programmatically creating a Scrollbar. In my case, I'm getting "TypeError: Error #2007: Parameter child must be non-null" errors.

    I haven't quite pinpointed the culprit yet. You're more than welcome to provide a tip. Keep it real!

  9. sConvey says:

    hey I am loving what I think this does
    and can't wait until #3
    but was wondering if a fla could at all be provided.
    (I know it seems lazy but I am very visual and things click so quick
    if I have a fla accompaniment)
    I am currently playing with it and It is not working the way I know it should which I am certain is because I am missing something (read the article 4x ;-) )
    either way thanks

  10. Marvin Blase says:

    hey everyone, sorry for letting you wait for some days, haven't been able to response here.. but now :)

    @Patrick Hill: well, this one's might occur because of the missing button-instances on stage. i will upload an example-fla tonight which might help you then!

    @Michael Roebuck: thanks - i'm not quite sure why this happens, but i guess the error depends on a timing problem. the swfs try to execute the code in their docclass/first frames though not completely initiated. try to use the INIT-event instead of COMPLETE. maybe send me your files so i can have a closer look at them..

    @sConvey: hey, inasmuch? i mean, what's wrong? :) without any information i can't do too much but my first guess is "are the button-instances on your stage declared with names?" - because the lines 59-61 are trying to add eventlistener to movieclips which are already on stage (with these names in properties-window set). keep on asking, i'm always glad to help :)

  11. sConvey says:

    Marvin thanks for the response.
    I have 3 buttons on my stage, each appropriately instantiated.
    I have also created a MC instantiated as contentContainer
    in the same directory as my .fla I have three swf's named 00, 01, 02.swf
    when I test the swf's independently using flash player they play correctly.

    however when I attempt to load them into the .fla using this code I get many
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    errors.

    I am using in each of the swf's a component called slideshowpro/ and thumbgrid
    (as the content I want to load are the galleries on my site) and their names are often referenced in the errors.

    I do have all of the image data, xml files and everything else needed to play those swfs in the
    same directory...

    any ideas?

    I am sure I am dong something silly. I am quite new to loading external files and also still relatively green to coding in general.
    thanks for your help... cheers

  12. Colin says:

    Fantastic tutorial, thanks. As with most people here, I'm trying to grasp AS3, this has been very helpful. I was able to get everything working, however, when you select a button to load the .swf, how do you do a crossover fade? I would like to have a smooth transition from 00.swf to 01.swf etc. I'm able to get the swf to fade in, but only after you remove the previous clip. Is there a way to remove the clip once the next one has loaded.

    Thanks... Colin

  13. Ben says:

    Could you post the code without all the line numbers? We can't copy and paste with all that in there. Thanks!

  14. Ralph W. says:

    just use the plain text button at the top left corner.

  15. Desperate says:

    I'm new to flash and have been trying to figure out how to load a series of swf files, one after the other without any button. That is after swfFile01 completes, swfFile02 begins, and after it completes, swfFile03, etc.

    Thanks.

  16. johannes says:

    can this be used for a gallery where the thumbnails are "synched", ie. when the first thumbnail is loaded it begins to load next and so forth. i tried to "hack" it in order to do so but my limited AS3 skills doesn't let me.. :-)

    right now I load about 20 thumbnails all at once, it slows the whole thing down, plus it doesn't look that good when it's added to the stage randomly.

  17. Marvin Blase says:

    hey johannes,
    for sure - this it what it's all about :) just use the last snippet loads multiple swfs sequentially, means one after another. in the end you've got an array holding all your loaded clips, accessible with clipsArr[0] for the first one, e.g.

    i'm going to publish part #3 soon, especially going deeper into building a gallery that way.

  18. Jessica says:

    This is EXACTLY what I needed after three days of blood, sweat and tears! I am absolutely over the moon to finally get the coding side of my website sorted. Thank you SO much for sharing this.

  19. Adam Lapczynski says:

    This is a great tutorial that really breaks down how to properly preload multiple swfs. this can easily be applied to images. Thanks!
    Another tool I've used on multiple occasions to preload all swfs or images at once is team2p0's implementation, that also returns an array of files you wish to preload

    http://www.microhome.com.co/com/team2p0/Preload.as

  20. estong says:

    simply awesome! thanks

  21. Archut says:

    Thanks for this excellent read. I liked every little bit of it. I bookmarked this and will be reading again.

  22. MJP says:

    Very nice thank you but as a previous poster wrote this snippet of code will not load my xml scroller (Error #1009: Cannot access a property or method of a null object reference.) that's contained in my external swf. The snippet from your chapter 1 will load the scroller though. hmmmm....

  23. Marvin Blase says:

    Where & how do you want to access it?

  24. Hallabak says:

    I get this message.

    ReferenceError: Error #1056: Cannot create property customID on _1_fla.MainTimeline__Preloader__.
    at MainTimeline_fla::MainTimeline/onSwfComplete()

    Here is my code:

    var _swfLoader:Loader;
    var _swfRequest:URLRequest;

    var _swfPathArr:Array = new Array("_1.swf", "_2.swf", "_3.swf", "_4.swf", "_5.swf", "_6.swf");

    var _swfClipsArr:Array = new Array();
    var _swfTempClip:MovieClip;
    var _loadedSWFs:int;

    startLoading(_swfPathArr);

    function startLoading(pathArr:Array):void {
    _swfLoader = new Loader();
    _swfRequest = new URLRequest();

    loadSWF(pathArr[0]);
    }

    function loadSWF(path:String):void {
    setupListeners(_swfLoader.contentLoaderInfo);

    _swfRequest.url = path;
    _swfLoader.load(_swfRequest);
    }

    function setupListeners(dispatcher:IEventDispatcher):void {
    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    }

    function currentSwfProgress(event:ProgressEvent):void {
    var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
    // swfPreloader.percentTF.text = _perc + "%";
    }

    function onSwfComplete(event:Event):void {
    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);

    _swfTempClip = event.target.content;
    _swfTempClip.customID = _loadedSWFs;
    _swfClipsArr.push(_swfTempClip);

    if(_loadedSWFs <_swfPathArr.length - 1) {
    _loadedSWFs++;
    loadSWF(_swfPathArr[_loadedSWFs]);
    } else {
    _swfLoader.unloadAndStop();
    _swfLoader = null;
    onCompletePreloading();
    }
    }

    function onCompletePreloading():void {
    contentContainer.addChild(_swfClipsArr[0]);

    _1.addEventListener(MouseEvent.CLICK, setContent);
    _2.addEventListener(MouseEvent.CLICK, setContent);
    _3.addEventListener(MouseEvent.CLICK, setContent);
    _4.addEventListener(MouseEvent.CLICK, setContent);
    _5.addEventListener(MouseEvent.CLICK, setContent);
    _6.addEventListener(MouseEvent.CLICK, setContent);
    }

    function setContent(event:MouseEvent):void {
    var _swfToAdd:MovieClip;

    switch(event.target.name) {
    case "_1":
    _swfToAdd = _swfClipsArr[0];
    break;

    case "_2":
    _swfToAdd = _swfClipsArr[1];
    break;

    case "_3":
    _swfToAdd = _swfClipsArr[2];
    break;

    case "_4":
    _swfToAdd = _swfClipsArr[2];
    break;

    case "_5":
    _swfToAdd = _swfClipsArr[2];
    break;

    case "_6":
    _swfToAdd = _swfClipsArr[2];
    break;
    }

    contentContainer.removeChildAt(contentContainer.numChildren-1);
    contentContainer.addChild(_swfToAdd);
    trace(_swfToAdd.customID);
    }

    Any Ideas?

    Also... when are we gonna see that 3rd tutorial?

    Thanks a bunch

  25. Marvin Blase says:

    Hey Hallabak,
    what happens if you cast _swfTempClip as a MovieClip before assigning the customID-property? Like _swfTempClip = MovieClip(event.target.content);

    A third tutorial is still in progress but will come soon - thanks for reminding me :)

  26. Hey guys, I'm running into a problem. I'm receiving these errors:

    1061: Call to a possibly undefined method unloadAndStop through a reference with static type flash.display:Loader.

  27. ...as well as: 1120: Access of undefined property contentContainer.

  28. Marvin Blase says:

    Hey Patrick,
    a) you have to use Flash Player 10
    b) you have to set up a clip named contentContainer to the stage.

  29. Marvin,

    Thanks for your reply. I didn't realize I had to publish it in Flash Player 10, which is tricky with CS3...but I found a way. Yes, I dropped the contentContainer on the stage, but put it on the wrong place (I had to put it inside the movieClip where my button was). All is well now. I can't begin to tell you how much this post and site have helped me. Thank you so very much.

  30. Marvin Blase says:

    You're welcome :)

  31. Hey Marvin, I'm back. :( So, I thought I had this thing licked, but now I'm getting another error...the same one that Hallaback is getting. I didn't get this error until upgrading to CS5 two days ago and voila, I'm getting ReferenceError: Error #1056: Cannot create property customID on test1_fla.MainTimeline__Preloader__.at test/onSwfComplete().

    I've read quite a bit about the built in preloader in CS5 and tried everything I could find on the internet (mainly messing with the AS3 advanced publish setting) to no avail. I also tried your suggestion to Hallback, but it didn't work. Can you think of anything else?

    My code:

    var _swfLoader:Loader;
    var _swfRequest:URLRequest;
    var _swfPathArr:Array = new Array("test1.swf", "test2.swf", "test3.swf");
    var _swfClipsArr:Array = new Array();
    var _swfTempClip:MovieClip;
    var _loadedSWFs:int;
    startLoading(_swfPathArr);
    function startLoading(pathArr:Array):void {
    _swfLoader = new Loader();
    _swfRequest = new URLRequest();
    loadSWF(pathArr[0]);
    }
    function loadSWF(path:String):void {
    setupListeners(_swfLoader.contentLoaderInfo);
    _swfRequest.url = path;
    _swfLoader.load(_swfRequest);
    }
    function setupListeners(dispatcher:IEventDispatcher):void {
    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    }
    function currentSwfProgress(event:ProgressEvent):void {
    var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
    // swfPreloader.percentTF.text = _perc + "%";
    }
    function onSwfComplete(event:Event):void {
    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    _swfTempClip = event.target.content;
    _swfTempClip.customID = _loadedSWFs;
    _swfClipsArr.push(_swfTempClip);
    if(_loadedSWFs <_swfPathArr.length - 1) {
    _loadedSWFs++;
    loadSWF(_swfPathArr[_loadedSWFs]);
    } else {
    _swfLoader.unloadAndStop();
    _swfLoader = null;
    onCompletePreloading();
    }
    }
    function onCompletePreloading():void {
    contentContainer.addChild(_swfClipsArr[0]);
    news_btn.addEventListener(MouseEvent.CLICK, setContent);
    portfolio_btn.addEventListener(MouseEvent.CLICK, setContent);
    contact_btn.addEventListener(MouseEvent.CLICK, setContent);
    }
    function setContent(event:MouseEvent):void {
    var _swfToAdd:MovieClip;
    switch(event.target.name) {
    case "news_btn":
    _swfToAdd = _swfClipsArr[0];
    break;
    case "portfolio_btn":
    _swfToAdd = _swfClipsArr[1];
    break;
    case "contact_btn":
    _swfToAdd = _swfClipsArr[2];
    break;
    }
    contentContainer.removeChildAt(contentContainer.numChildren-1);
    contentContainer.addChild(_swfToAdd);
    trace(_swfToAdd.customID);
    }

  32. Gabriel Sanchez says:

    HELP!!

    Im a graphic designer aka a copy and past actionscripter. LOL!~

    Im getting this error... Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@28eeadc1 to flash.display.MovieClip.

  33. LauraM says:

    I was happy to find this code..yet :(
    Patrick Brown I am getting the same error - yes I have CS5.

    Gabriel - I got the same error (Error #1034)- when I tried to load a Captivate made SWF..

  34. Marvin Blase says:

    hi laura, patrick,
    you're both using CS5? i don't know why (yet!) but it really does compile code somewhat different to cs4 ALTHOUGH this is nearly impossible to think of. but i myself have got a project which works flawlessly in cs4 but compiling it in cs5 it throws reference errors. this is one of the most weird things i ever came across while working in the ide.

    anyways - can one of you (or both) send me your .fla files? i'll give it a shot then.

  35. andras says:

    You saved my day Marvin, thank you very much!

    I've tried the COMPLETE replaced by an INIT listener but still throws that "Parameter child must be non null". I am wondering is it because the swfs in the array are not instanciated with a new ...() command?

    As i see you haven't published the 3rd serie of these articles:) Can we perhaps wait for it or you rejected the idea?

  36. TAK says:

    Anyone get this error or know how to fix it? I've been struggling for a few days now!

    Error: Error #2069: The Loader class does not implement this method.
    at Error$/throwError()
    at flash.display::Loader/addChild()
    at ProfileManagementWORKING_fla::MainTimeline/onCompletePreloading()
    at ProfileManagementWORKING_fla::MainTimeline/onSwfComplete()

    function onCompletePreloading():void {
    contentContainer.addChild(_swfClipsArr[0]);

    ed.addEventListener(MouseEvent.CLICK, setContent);
    daveh.addEventListener(MouseEvent.CLICK, setContent);
    davec.addEventListener(MouseEvent.CLICK, setContent);
    objB.visible = true
    percentLoaded.visible = false;
    trace("COMPLETE5");
    }

    I'm assuming it's the contentContainer.addChild(_swfClipsArr[0]); line?

  37. Josh says:

    Would it be possible to post your work files? BTW I'm getting the following error (on CS5): ReferenceError: Error #1056: Cannot create property customID on s_fla.MainTimeline__Preloader__.
    at s_fla::MainTimeline/onSwfComplete()

  38. Mimi says:

    Hi marvin.
    Thanks for your work.
    I have this error (I'm using CS4):

    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@bbc3701 to flash.display.MovieClip.
    at LoadMultipleSWFs_fla::MainTimeline/onSwfComplete()

    Feedback will be appreciated.

  39. Paolo says:

    firstly, sorry for the double post.. my laptop has been doing some odd things lately with the trackpad.

    moreso to the point though, I've tried this code on Flash CS5, and it doesn't seem to compile at all.

    On Flash CS5 I keep getting: ReferenceError: Error #1056: Cannot create property customID on _1_fla.MainTimeline__Preloader__.

    I've read up on the other posts here, and tried the suggestions like casting _sefTempClip as a MovieClip before the customID, as well unchecking and checking the "Automatically declare stage instances" checkbox, and I'm still getting the same thing.

    Next thing I may do is just save it as a CS4 document, but that's a shot in the dark right now. :/

  40. Bruce says:

    Great code, but I have the same problem as Patrick and Hallaback. I'm using CS5

    Error #1056: Cannot create property customID on test1_fla.MainTimeline__Preloader__.at test/onSwfComplete().

    Any headway with the compiling issues with CS5 vs CS4?

  41. Marvin Blase says:

    Hey all,
    first of all thanks for your comments. I was a bit too stressed out lately to reply. I have to admit, that something really, really weird has changed from CS4 to CS5. I had a talk with Adobe on that and it seams like there has been some framework based changes which lead to different variable-access times. I'll try to rework this post for CS5 asap!

    @TAK: can you show your declaration of contentContainer? or is it just a clip on stage?
    @Josh: CS5, yup.. really weird.
    @Paolo: ...
    @Bruce: ...

    Please keep being patient for some more days.

  42. greatxam says:

    to those who have encounter error on onSwfComplete listener, try to change this code:

    _swfTempClip.customID = _loadedSWF;

    to this:

    _swfTempClip.customID = _loadedSWFs;

  43. Juan says:

    first, thanks for this code, its been really healpful.

    im having some issues with it, i got it working in my local machine..but on webserver i cant get the parent to load th 3 swfs...any suggestions?

  44. Juan says:

    just found out what was wrong, might be about paths or domains..im new at as3 so cant figure out how to change the code..
    my file structure was like this:
    (only loads main..no swfs)
    home.html
    swf/
    |--main.swf
    |--00.swf
    |--01.swf
    |--02.swf

    this one works (everything in the same folder)
    home.html
    main.swf
    00.swf
    01.swf
    02.swf

  45. nettod says:

    hi, i cannot use the code! Display this error:

    1120: Access of undefined property _swfLoader.
    1120: Access of undefined property _swfRequest.

    do you know why???

  46. Razz says:

    I discovered the problem more specific to those interested, it seems this TLF textfield course the problem. So the easiest thing is to changes these (if you can).

    Otherwise look here for workaround:

    http://www.stevensacks.net/2010/05/28/flash-cs5-tlf-engine-causes-errors-with-loaded-swfs/

    I didnt have to typecast or uncheck anything in Actionscript 3 settings as suggest above.

    Hope it helps someone.

    Rasmus

  47. Daniel says:

    Razz was right. I was having the same issue (__PreLoader__) but all I had to do to fix it in CS5 was go to Publish Settings >> Flash Tab >> Actionscript settings... and change the Default Linkage at the bottom to Merge into Code. Then I republished the swf I was loading and it worked perfectly!

  48. Marvin Blase says:

    Hey,
    thanks for your feedback. Weird stuff but anyways, I'm planning the next article on that topic soon as there are some new perspectives open to me that I'd like to share. So.. yea, glad you managed to get it up and running in the end. :)

  49. Hi,
    Just wanted to send thanks for your well written article. I'm learning Actionscript 3 and enjoying it whilst tearing my hair out. Found your article on day 2 of trying to solve this one. Books help, but a 'straight to solution' help site like yours is terrific. Got it working using .as files rather than timeline code - due to your clarity - very much looking forward to your next article on this subject. I'm now going to apply it to my own project...

    Thanks again.
    Ruthine

  50. Duc says:

    Hey Marvin, what if I want multiple swfs to play like a presentation (one after the other) and not have a "Click" action? Thanks

  51. antandbee says:

    hello bubdy, your code is great. I have one question more. if file "00.swf" need to load some files "Image.jpg" more, how to make preloader for all of them, example:
    -"00.swf"
    -"image01.jpg"
    -"image02.jpg"
    -"image03.jpg"
    -"image04.jpg"
    -"01.swf",
    -"02.swf

  52. antandbee says:

    hello bubdy, your code is great. I have one question more. if file "00.swf" need to load some files "Image.jpg" more, how to make preloader for all of them, example:
    -"00.swf"
    |----"image01.jpg"
    |----"image02.jpg"
    |----"image03.jpg"
    |----"image04.jpg"
    -"01.swf",
    -"02.swf

  53. Scene 1, Layer 'Layer 1', Frame 1, Line 59 1120: Access of undefined property news_btn.

    Scene 1, Layer 'Layer 1', Frame 1, Line 60 1120: Access of undefined property portfolio_btn.

    Scene 1, Layer 'Layer 1', Frame 1, Line 61 1120: Access of undefined property contact_btn.

    I keep getting this Compiler Error

  54. David Woods says:

    I have a question. I am using the code and it works great when I run it from my desktop. The problem occurs when I run it online. Only the last swf loaded plays. The others are "paused?"

    I have 4 swfs, all are simple with no code. Just an animation that loops. I have my buttons set up to switch the loaded swf.

    What happens is that when I click the buttons, the clips switch but only the last clip in the array actually plays. This needs to work on IE 8, and flashplayer 10.3.

    Just to test, I switched the order of the swfs in the array and again only the last loaded swf plays so I know it isn't the swfs causing the problem. I suspect it is IE 8.

  55. Yo says:

    Hi, as duc asked, it would be really nice to know how to make it work like a presentation one swf after onother, without have mouse events

    Thanks ! Very usefull code !

  56. Marcus Olley says:

    Hi marvin,

    Im using Flash CS5 AS3 and it all seems to work ok but how would i use this line of code // swfPreloader.percentTF.text = _perc + "%"; to add a preloader and is this for all swf's? Also how could you tween the swf's being loaded and unloaded?

    kind regards

    Marcus Olley

  57. ...Need your help! I am using Concrete5 CMS and need Flash help.
    I am looking to load "multiple" swf [flash] files (as in the image Slideshow) on the header block of the default template (parent page) to show all across on the selected child pages.
    - note: FYI - I need multiple swf files, because each has its own animation and I want it to load randomly, not in the same order (otherwise I'd just make one long flash mov).

    Now I want to able to load multiple swf files (15-20 files), on the header, like so...
    1. Load swf file and play/remain on stage for say... 30 seconds each
    2. unload and simultaneously repeat the process
    3. must load random swf as if it was an images slideshow.

    Any suggestions? Thanks for your help.

    //G

  58. manju says:

    its not good please provide another one which is better than this.

  59. WRV90 says:

    Works great! Thanks!

  60. Berny Engström says:

    Thank you! I´ve been looking for this. Works fine!

  61. Suraj says:

    Hi Marvin,

    Thanks a lot. As I am beginner in AS3, this article helped me to think about everything before starting any loading stuff project further.
    I tried your code, it works fine. But how to play the loaded swf from beginning of click. The swf stays still on second click. swf is captivate
    generated flash file. I use captivate 5 and flash cs5.5.

    Thanks again and waiting for 3rd part of THE FINER ART OF LOADING.
    Suraj

  62. Suraj says:

    Hi Marvin,

    Can u check this code, it works fine for me, tell me if there is any wrong coding .. or any improvement to be done ..

    import flash.display.MovieClip;

    var swfLoader:Loader;
    var swfRequest:URLRequest;

    var swfPathArr:Array = new Array("scene/slide_1.swf","scene/slide_2.swf","scene/slide_3.swf","scene/slide_4.swf");
    var swfClipsArr:Array = new Array();
    var swfCount:int=0;
    var swfLoadCount:int=0;

    loadSWF();

    function loadSWF():void
    {
    swfLoader = new Loader();
    swfRequest = new URLRequest();
    swfLoader = new Loader();
    swfRequest = new URLRequest(swfPathArr[swfLoadCount]);
    setupListeners(swfLoader.contentLoaderInfo);
    swfLoader.load(swfRequest);
    }

    function setupListeners(dispatcher:IEventDispatcher):void
    {
    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    }

    function currentSwfProgress(event:ProgressEvent):void
    {
    var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
    percentTF.text = _perc + "%";
    }

    function onSwfComplete(event:Event):void
    {
    percentTF.text = "";
    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);

    swfClipsArr.push(MovieClip(event.target.content));

    if(swfLoadCount==0)
    displaySwf();

    if (swfLoadCount <swfPathArr.length-1)
    {
    swfLoadCount++;
    loadSWF();
    }
    else
    {
    swfLoader.unloadAndStop();
    swfLoader = null;
    }
    }

    function sceneStopHandler(evt:Event):void
    {
    removeEventListener("sceneStopEvent",sceneStopHandler);
    displaySwf();
    }

    function displaySwf():void
    {
    if (swfCount <swfClipsArr.length)
    {
    if(contentContainer.numChildren!=0)
    contentContainer.removeChildAt(contentContainer.numChildren-1);

    var tempMc:MovieClip;
    tempMc=swfClipsArr[swfCount];

    contentContainer.addChild(tempMc);

    tempMc.gotoAndPlay(1);

    // i have added dispatchEvent at the last frame of loaded swf
    addEventListener("sceneStopEvent",sceneStopHandler);

    swfCount++;
    }
    }

  63. Oded says:

    Wonderful tutorial!
    Did you ever get to write the 3rd part in the series?

  64. Hello nice tutorial. But i am using Flash Builder 4.6.

    I would build nice sample like Custom Template for Installing Process like phpBB or WordPress and another :)

    I would say because i have beeen coded.
    var _swfPathArr:Array = new Array("install/screen_welcome.swf", "pages/screen_mainpage.swf", "pages/screen_error.swf");

    switch(event.target.name) {
    case process_install:
    _swfToAdd = _swfClipsArr[0];
    break;

    case process_completed:
    _swfToAdd = _swfClipsArr[1];
    break;

    default:
    _swfToAdd = _swfClipsArr[2];
    break;
    }

    And can i ask you because i have been got crazy error message :/

    Look like this. But i am not using MovieClip - I am using only swfLoader by Flex SDK 4.6:

    TypeError: Error #1006: value ist keine Funktion.
    at index/ssbInit()[C:\Users\Jens\Adobe Flash Builder 4.6\ssb_mainpage\src\index.mxml:37]
    at index/___index_Application1_creationComplete()[C:\Users\Jens\Adobe Flash Builder 4.6\ssb_mainpage\src\index.mxml:4]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:13152]
    at mx.core::UIComponent/set initialized()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:1818]
    at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:842]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]

    I would know because my nice page want load currect - If my page is not completed than my content page swf will write by Usser once Database- and FTP-Connections like phpBB 3.x or vBulletin Content Applications.

    Thanks for my help :) I will help you back :) Don't worry! I am sorry because i am deaf :/ Best regards SourceSkyBoxer

  65. Mallory says:

    When I open and close the external movie my navigation scripts don't work. The button on the root movie timeline no longer returns me to the root scene. It works fine before I opened and closed the external SWF.

  66. fatima says:

    Hi, I'm loading a external swf in my fla in as3 but I want to load this swf on all pages in my fla but I can't pleas help me to do this.
    In fact I want to load a contact us page in my fla on the pages and then I want to close this swf and see the pages again could you help me pleas?

  67. trupti says:

    Hello,
    Thanks for the nice tutorial.
    It works fine for me with CS5

    I need some help in adding text search feature for this.

    I have written code to extract text from the loaded swf.
    This code works fine if i load swf in UILoader on stage but does not work with dynamiclly created UILoaders.

    Here is the code

    .
    .
    .
    //swf loading code....
    _swfTempClip = (event.currentTarget);
    timeLineRef.textSearcher.AddSearchData(_loadedSWFs, _swfTempClip);

    swf's are loaded as explained in the tutorial. After loading each swf below function is called.

    public function AddSearchData(_pageNum:Number, _pageObj:Object):void
    {
    trace("add Search Data "+_pageNum);
    var tempPageObjS:Object = new Object();
    tempPageObjS = _pageObj;
    var tempMCS:MovieClip = new MovieClip();
    var tempSnapTextObjS:TextSnapshot;
    var tempStrS:String = new String();

    if(tempPageObjS != null && tempPageObjS.toString() == "[object MainTimeline]")
    {
    trace("it is MC1")
    tempMCS = tempPageObjS as MovieClip;
    tempSnapTextObjS = tempMCS.textSnapshot;
    trace("tempSnapTextObjS "+tempSnapTextObjS.charCount)
    //strange thing is i'm getting proper count value for above trace
    tempStrS = tempSnapTextObjS.getText(0,tempSnapTextObjS.charCount,true);
    //but empty string below trace
    trace("tempStrS "+tempStrS);
    }
    }

    Am I missing something here?

    Thanks for any help! :)

  68. SourceSkyBoxer says:

    Hey folks,

    that is a great and excellent tutorial for Flash CS5.5 ( Pro ).

    I found trick like while and if-else for PHP -> exist with config.php for example.

    if your flash application gets initial process before you write database and wait for writing process by database :)

    Look like this. I invent that for without _btn>.addEventListener(MouseEvent.CLICK, setContent);

    Look this my code:
    var _swfLoader:Loader;
    var _swfRequest:URLRequest;

    var _swfPathLayoutDir:String = "templates/layouts/flash/";
    var _swfPathArr:Array = new Array(_swfPathLayoutDir+"index_start_layout.swf", _swfPathLayoutDir+"index_install_layout.swf");

    var _swfClipsArr:Array = new Array();
    var _swfTempClip:MovieClip;
    var _loadedSWFs:int;
    var _swfInstallCompleted:Boolean;

    startLoading(_swfPathArr);

    function startLoading(pathArr:Array):void
    {
    _swfLoader = new Loader();
    _swfRequest = new URLRequest();

    loadSWF(pathArr[0]);
    }

    function loadSWF(path:String):void
    {
    setupListeners(_swfLoader.contentLoaderInfo);

    _swfRequest.url = path;
    _swfLoader.load(_swfRequest);
    }

    function setupListeners(dispatcher:IEventDispatcher):void
    {
    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    }

    function currentSwfProgress(event:ProgressEvent):void
    {
    var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
    // swfPreloader.percentTF.text = _perc + "%";
    }

    function onSwfComplete(event:Event):void
    {
    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);

    _swfTempClip = event.target.content;
    _swfTempClip.customID = _loadedSWFs;
    _swfClipsArr.push(_swfTempClip);

    if (_loadedSWFs <_swfPathArr.length - 1)
    {
    _loadedSWFs++;
    loadSWF(_swfPathArr[_loadedSWFs]);
    }
    else
    {
    _swfLoader.unloadAndStop();
    _swfLoader = null;
    onCompletePreloading();
    }
    }

    function onCompletePreloading():void
    {
    contentContainer.addChild(_swfClipsArr[0]);
    var _swfToAdd:MovieClip;

    //while()
    //{
    if (_swfInstallCompleted == false)
    {
    _swfToAdd = _swfClipsArr[1];
    }
    else
    {
    _swfToAdd = _swfClipsArr[0];
    }
    //}

    contentContainer.removeChildAt(contentContainer.numChildren-1);
    contentContainer.addChild(_swfToAdd);
    trace(_swfToAdd.customID);
    }

    And you know about while-nstruction.
    If i need connect with PHP / Database or another web-services like asp, cf-script or J2EE... That is nice solution by my idea :) Thank you my dear!

    Best regards SourceSkyBoxer

  69. that guy says:

    This doesn't seem to work on Firefox 17 Win xp, flash player 11.5.502. Any idea why?

    It works on Internet Explorer and also Chrome for win xp tho.

    Works like a charm for any browsers on win7.

    I'm thankful for that code and the time you took to create it.

  70. Nuno says:

    Great Tuturial, but i get this error

    TypeError: Error #1034: Falha de coerção de tipo: não é possível converter flash.display::Bitmap@1fe5ffa9 em flash.display.MovieClip. at loader_2_fla::MainTimeline/onSwfComplete()

    any ideas why?

    Thanks in advance

  71. Ashleigh says:

    Hi Marvin,

    I'm trying to teach myself AS 3.0 to build an app, and your code is great - thank you. I have tweaked it slightly so files toggle between a prev and next button and all is good except I am accessing it by a mouseclick event on a different page and it only works the first time, the second time the files don't load.
    Any chance you know why that might be? Here is my code.
    Cheers,
    Ashleigh

    import flash.events.MouseEvent;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.Sprite;

    menuPage_mc.movie_btn.addEventListener(MouseEvent.CLICK, playClicked);

    function playClicked(event:MouseEvent):void
    {
    var _swfLoader:Loader;
    var _swfRequest:URLRequest;

    var _swfPathArr:Array = new Array("swf/movie0.swf","swf/movie1.swf","swf/movie2.swf","swf/movie3.swf");

    var _swfClipsArr:Array = new Array();
    var _swfTempClip:MovieClip;
    var _loadedSWFs:int;

    menuPage_mc.visible = false;

    startLoading(_swfPathArr);
    function startLoading(pathArr:Array):void
    {
    _swfLoader = new Loader();
    _swfRequest = new URLRequest();
    loadSWF(pathArr[0]);
    }

    function loadSWF(path:String):void
    {
    setupListeners(_swfLoader.contentLoaderInfo);
    _swfRequest.url = path;
    _swfLoader.load(_swfRequest);
    }

    function setupListeners(dispatcher:IEventDispatcher):void
    {
    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    }

    function currentSwfProgress(event:ProgressEvent):void
    {
    var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
    // swfPreloader.percentTF.text = _perc + "%";
    }

    function onSwfComplete(event:Event):void
    {
    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);

    _swfTempClip = event.target.content;
    _swfTempClip.customID = _loadedSWFs;
    _swfClipsArr.push(_swfTempClip);

    if (_loadedSWFs <_swfPathArr.length - 1)
    {
    _loadedSWFs++;
    loadSWF(_swfPathArr[_loadedSWFs]);
    }
    else
    {
    _swfLoader.unloadAndStop();
    _swfLoader = null;
    onCompletePreloading();
    }
    }

    function onCompletePreloading():void
    {

    _loadedSWFs = 0;
    moviePage.addChild(_swfClipsArr[_loadedSWFs]);
    next_btn.addEventListener(MouseEvent.CLICK, setContent);
    prev_btn.addEventListener(MouseEvent.CLICK, setContent);
    }

    function setContent(event:MouseEvent):void
    {
    var _swfToAdd:MovieClip;
    if (event.currentTarget.name == "next_btn")
    {
    _loadedSWFs += 1;
    if (_loadedSWFs == _swfClipsArr.length)
    {
    _loadedSWFs = 0;
    }

    }
    else if (event.currentTarget.name == "prev_btn")
    {
    _loadedSWFs -= 1;
    if (_loadedSWFs == -1)
    {
    _loadedSWFs = _swfClipsArr.length - 1;

    }

    }
    _swfToAdd = _swfClipsArr[_loadedSWFs];
    moviePage.removeChildAt(moviePage.numChildren-1);
    moviePage.addChild(_swfToAdd);
    trace("_swfToAdd.customID");
    }
    }

    menu.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
    {
    moviePage.visible = false;
    menuPage_mc.visible = true;
    }

  72. cam sites says:

    Thank you for yet another great post. Exactly where in addition might anybody get that kind of info such an affordable way involving creating? We've a presentation in the near future, using this program . for the search for this kind of data.

  73. klauday says:

    thanks. :)

Leave a Reply

Powered by WordPress | Free T-Mobile Phones for Sale | Thanks to Palm Pre Blog, Video Game Music and Get Six Pack Abs