A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Dynamically loading sequential swfs w/o using buttons

  1. #1
    Junior Member
    Join Date
    Aug 2005
    Posts
    3

    Dynamically loading sequential swfs w/o using buttons

    Hi all, and let me just say THANK YOU in advance for any help I may receive, I know how valuable your time is. I'm not a total Flash newbie, but I'm not a pro with Actionscript.

    Here's my situation:

    - Flash CS4 Actionscript 2.0 internal training project

    - Main movie is a single frame project, containing just the interface. This includes a menu listing 80+ individual "chapters" for the training series.

    - Each "chapter" is its own project/swf. Once the main interface loads, it should begin to play the chapters sequentially without the user selecting anything from the menu. When one chapter finishes, the next should load. If the user DOES select a chapter in the menu, it should load that SWF, and continue auto-playing from that selection forward.

    - Each chapter has a built-in play/rewind/ff bar, various movie clips with animations, dialogue audio track and a fairly lengthy embedded FLV movie, and therefore a preloader before each chapter is mandatory.


    What I have so far works, but it's embarrassingly crafted:

    - First frame of main movie (let's call this main.fla) contains the following code (most of this code was taken from an online tutorial):


    var slideName = "modules/intro.swf";
    var loader:MovieClipLoader = new MovieClipLoader();
    loader.addListener(this);
    loader.loadClip(slideName, _root.movie);



    _root.movie refers to an empty movie clip that is positioned on the stage of main.fla. Then, the last frame of each chapter swf contains the following code:


    _root.slideName = "modules/01.swf";
    var loader:MovieClipLoader = new MovieClipLoader();
    loader.addListener(this);
    loader.loadClip(_root.slideName, _root.movie);



    The goal was to have each chapter tell the main timeline which movie to load next just by passing the slideName variable, but that didn't work so in desperation I ended up adding the loader.loadclip AS to the end of each swf, a cluttery, inelegant solution but it works. There has to be a better way!

    Debugger tells me the variables ARE being passed to the main movie as expected. I'm assuming the "variables-only" method I tried fails because the loader.loadclip AS in my main movie only fires on first load and never again, but I'm just not good enough with AS to figure out how to build a function that works as expected.

    - SO HERE'S MY QUESTION -

    I would prefer to use the slideName variable to load subsequent SWFs in the main movie as outlined above, because that variable also ties into other functionality such as highlighting the current chapter in the main menu. But really, I just need a working solution that isn't so clunky so if there is a better way to handle all of this, I am definitely open to ideas if they work.

    I also need to have a progressBar preloader as each chapter loads because they can be up to several MBytes in size. Using the above code, and random tutorials on progressBar preloading, I got it to sorta work but it was unreliable and clearly something was wrong. I understand that the preloader scripting needs to live in the main presentation, but I can't get a reliable working solution.


    Thanks again for any input you guys might have!!!

  2. #2
    Junior Member
    Join Date
    Aug 2005
    Posts
    3
    One thing I forgot to mention - each chapter varies in length, so any solution I implement can't be based on a timer-type approach.

    Thanks!

Tags for this Thread

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