Play exit animations on multiple external SWF's?

Hi,
Here is what I would like to do: I have some buttons, then 2
movie clips named container and container2. When I click on a
button, an external SWF is loaded into container. I have it working
so that when another button is clicked, it plays the exit animation
of the current SWF, then loads the new one. Here is the code that I
used for that:
on a button:
Code:
on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = "who";
container.loadMovie("who.swf");
} else if (_root.currMovie != "who") {
if (container._currentframe >= container.midframe) {
_root.currMovie = "who";
container.play();
In who.swf frame 1:
Code:
midframe = 114;
In who.swf last frame:
Code:
_root.currMovie = undefined;
stop();
Frame 114 is where the exit animation starts.
What I would like to do, is have a button in who.swf, that
will load another external swf into container2, while leaving
who.swf in place. Then, when one of the main buttons is clicked, I
would like it to play the exit animation of the swf that is
currently in container2, then play the exit animation of the swf
that is currently in container, then load the new swf into
container. Can someone please help me out with the code for that?
Thanks!

the thing is that i had to keep a reference to my Loader.
if you dont keep a reference to the Loader who is processing the loadBytes(), the Garbage Collector could close the Loader, wich causes the loader to unload.
i tried this with a test, i load 1 swf binary with an urlloader, and in the complete-event i create 100 loaders wich do a loadBytes on the loaded bytes.
the FlashBuilder console traces 100x [SWF] <path> 1000 bytes after decompression, and sometimes i get a whole bunch of [Unload SWF]
this is because i dont keep any reference to the Loader. if i would keep a reference to the loader stored in an array, i dont get the unload. when the loader is done, you can store the content in a variable, and remove the loader, but as long as its loading, you should keep a reference to the loader.
Hope this helps others.
p.s.  i keep seeing [SWF] Main.swf instead of [SWF] <loaded swf file> is because i load the swf with an URLLoader (wich gives no trace), but when i do a loadBytes, it doesnt know its path anymore, so you get the root-swf, Main.swf in this case.

Similar Messages

  • How to load and unload Multiple External SWF

    hello there,
    i need help to figuring out how to load and also unload(removing) multiple external SWF.
    so here is what i;m trying to do,
    i want to load multiple external SWF and play it on my main SWF now i hove no problem with just loading multiple SWF and placing it in the display list .The problem came up when i tried removing those loaded SWF from the display list ,The problem exist because i have no way to refer to what i have loaded and placed on the display list,
    i used a single loader instance to load all that external swf,
    i do know that we have to remove all the event listener related to the external SWF that we want to remove and for this purpose i have crated a function called destroy which the main objective for this function is to remove all event listener inside the swf and also isolating all variable so it would be eligible for garbage collecting, here is what the code look like:
    // Create this in every object you use
    public function destroy():void
         // Remove event listeners
         // Remove anything in the display list
         // Clear the references to other objects, so it gets totally isolated
    sorry it just a kind of pseudocode cause this function will customize with it's own property i did this just for the purpose of simplicity and easy understanding..,
    so now back to main problem how should i solve this problem??
    i tried used an arraf to save all the loaded swf
         the array is just used to save the what the loader is loading but the adding to display method is using
    movieClipActAsContainer.addChild(e.target.content); //the event is from the Event.COMPLETE
    but i have a hard time using that arrya back and matching it to the one i got from the display list.
    please do help me,
    any suggestion would be greatly appreciated,
    and if can pleas show me a source code or pseudocode of what you're suggesting to me cause my english is not so fluent yet,
    thanks before.

    Hey EI,
    I had done this kind of project recently and for loading and unloading different swfs. I had used loaders specific to that filename and for removing I had used a single movieclip instance name and on clicking that specific loader request name that needs to be removed will be requested from the specific function. As mentioned below
    Loading SWF:
    ===============================
    swfLoaderIndia.load(swfRequestIndia);//This will load the request
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).addChild(swfLoaderIndia);//This will load swf on stage
    or else
    Stage.addChild(swfLoaderIndia);
    Unloading SWF
    =====================================
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).removeChild(swfLoaderIndia);//This will unload swf on stage
    or else
    Stage.removeChild(swfLoaderIndia);
    Above code will be in specific function which will be requested when the loading and unloading is required.
    I hope this helps you in your project.
    With Regards,
    Sagar S. Ranpise

  • Controlling multiple external swfs from main timeline

    Hi, I've been trying to combine the features of two tutorials I found, one that deals with controlling external swf's from the main timeline and the other that explains how to load and unload multiple external swf's.  I'd like to be able to load and unload multiple external swf's, and control these swf's buttons from the main timeline. 
    I asked this same question on the forum of the site where I found these tutorials, and receive only one reply saying that "it should'nt be hard to do." but they did not elaborate any further.  This left me think that I was missing something very obvious and I've spent too much time now trying to work what it is now.  I understand pretty much how both pieces of code work, but just can't work out how to combine them.
    If someone could explain it to me, I'd much appreciate it.
    Tutorial One code - controlling an external swf from the main timeline.
    var ldr:Loader = new Loader();
    var urlReq:URLRequest = new URLRequest("swfs/balls.swf");
    ldr.load(urlReq);
    function loadHandler (event:Event) {
    var myClip:MovieClip = event.target.content;
    addChild(myClip);
    function myClipOver(event:MouseEvent):void {
    myClip.myBlueBalls.stop();
    function myClipOut(event:MouseEvent):void {
    myClip.myBlueBalls.play();
    // set listeners
    myClip.addEventListener(MouseEvent.ROLL_OVER, myClipOver);
    myClip.addEventListener(MouseEvent.ROLL_OUT, myClipOut);
    // listener
    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler);
    Tutorial Two code - loading and unloading multiple external swfs.
    var Xpos:Number = 110;
    var Ypos:Number = 180;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = Xpos;
        loader.y = Ypos;
    addChild(loader);
    // Btn listeners
    eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
    stingray.addEventListener(MouseEvent.CLICK, btnClick);
    demon.addEventListener(MouseEvent.CLICK, btnClick);
    strongman.addEventListener(MouseEvent.CLICK, btnClick);

    I will not be able to help you with whatever relaxatraja provided though it is purported by relaxatraja to be clearly explaining what I was explaining (???).
    Your loadHandler function appears a bit confused.  For the code you show I don't see you assigning any event listeners for the events that will be dispatched in the loaded file.  As I showed earlier, your loadHandler function should be assigning a listener for the event that will be dispatched (modified slightly below). and if you have three different events being dispatched in the loaded file, then you'll do better to have three different listeners.  I show only one below for one of the events you dispatch...
    function loadHandler (event:Event) {
      // assign a listener for the loaded file's goExit function's event
       MovieClip(event.currentTarget.content).addEventListener("close", event1Handler);
    // I can't make sense of what you have here
        removeChild(myClip); // why ?? - it hasn't been added yet as far as I can see - error 2007?
        var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf"); // the event.target is the Loader
        ldr.load(newSWFRequest); // this will load over the file you just finished loading??
        ldr.x = Xpos;
        ldr.y = Ypos;
        addChild(myClip);  // why?? it has nothing in it
    function event1Handler(e:Event):void {
        // do whatever is involved with what the "close" event is supposed to do
        trace("goExit function executed");
    As far as what you have in the loaded file, you appear to be trying to pass the files names as if they were parameters.  The file naming should be done at the receiving side for the event handler function for the event listener.  While you could create a custom event that include parameters that you can pass, that's another level of coding that is better left for a future experience.
    Study the following - understand it before you try to use it.
    Below is a link to some files I made for another posting that demonstrates what I have been explaining.  The neurope file is the main file.  Publish the netherlands file so that you have an swf to load for it, and then run the neurope file.  The file that gets loaded (netherlands) only has a button in it that when clicked dispatches an event for which the main file (neurope) has assigned a listener.  The main file displays a message when the button gets clicked in the loaded file.
    http://www.nedwebs.com/Flash/neurope.zip

  • Play - Pause button for external .swf?

    I'm trying to create buttons so a viewer can pause and then play an externally loaded swf. My project can be accessed at the linke below. This is how I want the project to function
         -Click a room on the building (choose Accounting for this discussion)
         -Click one of the demo options (choose Ending a Period for this discussion)
         - Now that the demo plays, I want the user to be able to play and pause the demo swf.
    The demo .swfs were created in Captivate so I don't have access to their timeline. They are loaded into an empty Loader component using the MovieClipLoader Class. Can anyone post some possible solutions to this problem? Thanks!
    http://distribution.activant.com/demos/prophet21-on-demand/

    What would that look like? Right now they're loading using the following code:
    btnCashCollect_btn.onRelease = function () {
          mcLoader.loadClip("CashCollections.swf",myLoader);
          btnEndPeriod_btn.enabled = false;
          btnCashCollect_btn.enabled = false;
          btnFinancialMGMT_btn.enabled = false;
          _root.btnHome_mc._visible = false;
    So would I use something like:
    btnPause.onRelease = function() {
         myLoader.content.pause();
    Actually I just tried that and it didn't work...I need the buttons to work for multiple external swfs that will be loaded into myLoader

  • FAQ: How do I load an external SWF file into a parent SWF file?

    A ton of Flash users visit Adobe’s we site every month wondering  about how to load an external SWF file from within another SWF.
    Adobe's own TechNote on the subject attempts to answer the basic question, along with some common follow-up questions, including:
    How do I load more than one SWF?
    How do I load a SWF into a specific location in the display list?
    How do I resize the loaded SWF?
    How do I set its X and Y location?
    Here are some additional resources that elaborate on loading content and on working with the display list:
    Sample files for the above TechNote. A set of 3 FLA and 3 corresponding SWF files, including a parent SWF and 2 SWFs that the parent loads.
    Help > AS3 Developer’s Guide > Loading an external SWF file
    Help > AS3 Developer’s Guide > Loading display content dynamically
    Loading multiple external SWFs within a main SWF – CreativeCow.net forums
    Video tutorial: ActionScript 101 – Episode 6: Adding named objects to the Stage. By Doug Winnie. An example of how to add the loaded external asset to the Stage and modify its location or other properties.
    Video tutorial: Preloading in ActionScript 3.0.  By Lee Brimelow. A slightly more complicated example, showing how to  make the parent SWF display information about the progress of loading  the external SWF.
    Tutorial: Loading and unloading SWFs - FlashAndMath.com
    This article provides several examples of how to communicate between a parent SWF file and the loaded SWF:
    SWF to SWF Communcation via ActionScript 3.0 (by kglad)

    quote:
    Originally posted by:
    NedWebs
    You now seem to want to get rid of the swf once it has loaded
    and played itself thru. To do that you would need to have something
    in the swf itself that triggers its removal in its last frame. The
    following might work...
    MovieClip(this.parent).removeChild(this);
    Unfortunately I couldn't get this to work. I placed it on the
    last frame of the SWF to be called - is that right?
    I am not sure I am doing it correctly...

  • Further External SWF Issues

    So once again, I am trying to create seperate external SWFs for my site in order to drastically reduce load times and each SWF loads a different section of my portfolio. This code worked for the first external SWF:
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("flashfiles/bwphoto.swf");
    myLoader.load(url);
    bwanchor.addChild(myLoader);
    But now on a different area in the timeline when I try to use it on a different movie clip with a different SWF and URL, it doesn't work. It gives me two errors:
    1151: A conflict exists with definition myLoader in namespace internal
    1151: A conflict exists with definition url in namespace internal
    What do these mean? And does someone maybe just have a better code to unload and load multiple external SWFs? Keep in mind it can be just click to load, click again to unload because each SWF has its own navigation to change the image shown.
    Thanks again for any help.

    The errors seem to indicate that you are trying to declare the same variables again, namely 'myLoader' and 'url'.
    var myLoader:Loader = new Loader();
    var url:URLRequest ...
    When you use "var" you are declaring a variable.
    You cannot declare a variable more than once in a file.  So either use new variable names, or do not use the "var" declaration for any other times you use those variables in the file.  LAter in the timeline you could try using...
    myLoader = new Loader();
    url = new URLRequest("flashfiles/someother.swf");

  • Unload external SWF using event dispatch

    Hi i am working on a flash website where i have a main movie named as Navigation where i have all the navigation buttons and drop menus. i am using switch case method to load multiples external SWFs. so as user clicks on any of the navigation button...it loads the external SWF
    now i have a close_btn in the loaded SWF and i simply want the unload the external SWF when user clicks on the close_btn.
    I come to know that i can do this by event dispach but i am not sure what code to put in external swf  so when close_btn is clicked it can access the unloader function in main movie and unload the External SWF.
    Could you Please help, Thank you !
    this is my code
    //--------main swf---------------------
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.URLRequest;
              home_btn.addEventListener(MouseEvent.CLICK,Click_To_Close);
              ourstory_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              facility_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              customers_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              sustainability_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              contactus_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    //  Dropdown Menu1 Buttons
              menu1.menu_mc1.organicinitiative_btn.addEventListener(MouseEvent .CLICK, clickHandler);
              menu1.menu_mc1.myhope_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu1.menu_mc1.target2015_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    //  Dropdown Menu2 Buttons
              menu2.menu_mc2.mens_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu2.menu_mc2.womans_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu2.menu_mc2.teans_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu2.menu_mc2.babies_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    var loader:Loader = new Loader();
    addChildAt(loader,0);
    function clickHandler(e:Event):void{
    switch(e.target.name){
        case "ourstory_btn": loader.load(new URLRequest("ourstory.swf")); break;
        case "facility_btn": loader.load(new URLRequest("facility.swf")); break;
              case "customers_btn": loader.load(new URLRequest("customers.swf")); break;
              case "sustainability_btn": loader.load(new URLRequest("sustainability.swf")); break;
              case "contactus_btn": loader.load(new URLRequest("contactus.swf")); break;
              case "organicinitiative_btn": loader.load(new URLRequest("organicinitiative.swf")); break;
              case "myhope_btn": loader.load(new URLRequest("myhope.swf")); break;
              case "target2015_btn": loader.load(new URLRequest("target2015.swf")); break;
              case "mens_btn": loader.load(new URLRequest("mens.swf")); break;
              case "womans_btn": loader.load(new URLRequest("womans.swf")); break;
              case "teans_btn": loader.load(new URLRequest("teens.swf")); break;
              case "babies_btn": loader.load(new URLRequest("babies.swf")); break;
    //-----------my unloader function in main swf --------------------
    function Click_To_Close(event:MouseEvent):void
                  if(loader != null) {
         loader.unloadAndStop();

    thank you
    i have tried to use   this.parent.Click_To_Close  but it gives compilation error
    i checked the tutorial about custom events i think its little complex for me now to understand the typeriter app.
    also i cheked the similer thread and tried to test that code myself..i found that the last block of main movie does not works and does not unload the loader2. however  all the trace are showing in the output windows that i added to check the code but last trace from the main movie is not showig...   
    trace("child removed from Main Movie") 
    so if this can work somehow i will use this method of event dispatch in my application that i am working...
    Thank you
    -----main movie ---------
    var loader1:Loader = new Loader();
    var loader2:Loader = new Loader();
    loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, assignMovie1Listener);
    loader1.load(new URLRequest("movie_1.swf"));
    loader2.load(new URLRequest("movie_2.swf"));
    addChild(loader1);
    addChild(loader2);
    function assignMovie1Listener(evt:Event):void {
          MovieClip(evt.currentTarget.content).addEventListener("eventTriggered", removeLoader2);
                trace("listner is listning..")
    function removeLoader2(evt:Event):void {
          loader2.unloadAndStop();
          removeChild(loader2);
             loader2 = null;
                trace("child removed from Main Movie")
    //------------- movie_1.swf code:
    removeMovie2_btn.addEventListener(MouseEvent.CLICK , removeMovie2);
    function removeMovie2(event:MouseEvent):void
          dispatchEvent(new Event("eventTriggered"));
                trace("event triggered form Child Movie-1");
    as u can see when i click close button its triggering the trace from movie-1 but its not unloadign the movie2

  • Help with loading External SWFs

    Hi:
    I need to load external swfs into a mc. They will play in
    sequence, as soon as one ends, the next one will start. When
    running it blows by the first external swf (start.swf) and the rest
    of the external swfs will not continue to load and play after the
    objectives.swf. Could someone take a look at my code and tell me
    what I’m doing wrong?
    I’ve created controls that will allow me to play, pause
    and stop the external swfs while they’re playing (however,
    these buttons do not seem to have any effect on the external swf
    when it is playing). I think it is a scope issue, but I am not
    sure.
    Also, there’s a combo box at the bottom, which allows
    the user to jump to any external swf (it actually jumps to certain
    labels on the main timeline) at any time. The combo box appears to
    work OK.
    The FLA is located at:
    www.digitalhorizonstudios.com/exstream/newplayer.fla
    By the way, this presentation is a fullscreen .exe file when
    in use, not a swf played in an html file.
    Thanks SO MUCH for any help on this one.

    Please try this line of script:
    var myLoader:Loader = new Loader(); //create the varaible for the loader
    var myURL:URLRequest = new URLRequest("A.swf");// create the variable for the swf to be loaded
    myLoader.load(myURL)
    addChild(myLoader);

  • Button from External SWF to Play Movie in Main SWF

    Hi Guys,
    Ok I'm working in Flash 8, Action Script 2;
    I'm building a website, in which the 'Gallery Page' has a link to an external swf file, which is a scrolling clip of thumbnails.
    What I want to do, is create each thumbnail into a button, which will then play a Movie Clip from a frame located in the Main swf file.
    (So basically, each thumbnail button is a small photo, will play that photo in a large scale as a movie)
    eg.
    thumbnail1_btn  needs to go to main swf and play movieclip1.mc, frame 1
    thumbnail2_btn nends to go to main swf and play movieclip1.mc, frame 2
    I'm unsure of the code for this? Or if I've built this up wrong?
    If someone could help me out, that would be great!

    If you haven't set _lockroot on the loaded SWF, than a simple _root call from the loaded SWF will talk to the main SWF.
    IE:
    on(release){
    _root.gotoAndPlay(1);
    If you did set the lockroot, then call the level directly, via:
    on(release){
    _level0.gotoAndPlay(1);
    Once on the root level, you can access a movie clip as normal.
    So:
    on(release){
    _level0.movieClip1.gotoAndPlay(1);
    will call the movie clip "movieClip1" which resides on the timeline of _level0 (which is main.swf in your instance), and tell it to jump to the first frame and start playing.

  • Load and consecutively play external swf's

    Hi,
    I have three external swf files - part1, part2 and part3. I
    know how to load one clip but I would like to know how to
    dynamically load them into an empty MC and then play them in full
    consecutively without any fancy transitions so that it plays like
    one big movie using Actionscript (no button triggers!).
    I have some very BASIC actionscript knowledge but am not sure
    which way is best. If someone could give me some "simple" step by
    step advise it would be grately apreciated.
    Danielle

    Ok I followed your instructions and when I play the main swf
    (I call - load_swfs) file it plays part1.swf fine but then it gets
    to the first frame of part2.swf (which is blank) and just stops and
    doesn't go any farther! Did I put something in the wrong place?
    I've written what I did and where below.
    // In my main file (load_swfs) it's just a single blank frame
    with this code in it :-
    tl=this;
    swfA=["part1.swf","part2.swf","part3.swf"];
    dep=0;
    numLoaded = 0;
    totalLoad=3;
    lo=new Object();
    lo.onLoadInit=function(target){
    numLoaded++;
    checkIfAllLoaded();
    function checkIfAllLoaded(){
    if(numLoaded==totalLoad){
    holder1.play();
    } else {
    mc=this.createEmptyMovieClip("holder"+(numLoaded+1),dep++);
    mcl.loadClip(swfA[numLoaded],mc);
    mcl=new MovieClipLoader();
    mcl.addListener(lo);
    mc=this.createEmptyMovieClip("holder"+(numLoaded+1),dep++);
    mcl.loadClip(swfA[numLoaded],mc);
    // In part1.swf in the last frame is :-
    tl.holder2.play();
    this.removeMovieClip();
    // In part2.swf frame 1 is blank with a stop(); and in the
    last frame is:-
    tl.holder3.play();
    this.removeMovieClip();
    // In part3.swf frame 1 is blank with a stop();
    Let me know where I went wrong!
    Thanks

  • Call a external SWF by press the button within another SWF file but the second SWF file play Externely

    Hello Guyz.
    i am working on Macromedia Flash 8 and i just want to call a external SWF when i press the button within another SWF file.......but the second SWF file play Externely............can any one knows the code.... AS2

    try this
    http://www.actionscript.org/forums/showthread.php3?s=&threadid=28123

  • Preload external swf before play

    i have a project i am working on...but for some reason the solution i went with is not satisfying my instructor......
    so....here is my new code ( which is incorrect but i cant figure out how to arrange the preloader at the end )
    var Xpos:Number=0;
    var Ypos:Number=0;
    var swf:MovieClip;
    var bgloader:Loader = new Loader();
    var bgURL
    if(page==1){
    bgURL=new URLRequest("pages/home.swf");
    else if(page==2){
    bgURL=new URLRequest("pages/about.swf");
    else if(page==3){
    bgURL=new URLRequest("pages/projects.swf");
    else if(page==4){
    bgURL=new URLRequest("pages/experimental.swf");
    else if(page==5){
    bgURL=new URLRequest("pages/contact.swf");
    bgloader.load(bgURL);
    bgloader.x=Xpos;
    bgloader.y=Ypos;
    bg.addChild(bgloader);
    stop();
    var percent:Number = bgURL.bytesTotal;
    if(percent==100){
    gotoAndPlay("start");
    first off, i dont even know if what i am being asked to do is possible...but, what i am being requested to do is obviously load in the external swf BUT, the external swf cannot play until the MAIN swf is directed to "start"......
    i have done this numerous times in as1 and 2....but back then things were totally written different and if you do it the same way you run into migration issues....
    i thought this was solved already, but my instructor will not accept the method of using an event to be dispatched in the external SWF to tell the main swf when to play "start"....im not sure if there is any other way to do this?
    he wants the external swf to contain NO code other than what is necessary for its internal functions....
    everything is to be coded in the MAIN swf.....
    so im trying to use bytesTotal, and the percent==100 is just a number i threw in for example purposes.....i am just not figuring this out....
    any help is greatly appreciated

    From what I could gather based on your description, your instructor wants you to start playing when external swf is loaded completely.
    If my understanding is correct, what you need to do conceptually is:
    1. Instantiate Loader
    2. Add event listeners that you are interested in.
    3. Execute code corresponding to these listeners in their corresponding handler functions.
    As for No 2 - Usually there are at least 3 events that are of interest when dealing with Loaders:
    1. Event.COMPLETE - dispatched when entire target is loaded
    2. ProgressEvent.PROGRESS - dispatched when a new bytes packet arrives.
    3. IOErrorEvent.IO_ERROR - dispatched when something goes wrong with loading (say, wrong url, etc.)
    In your particular case it is supposed to be something like this (may not work because you did not describe what is the point of different swfs loading and how it affects entire application). SEE COMMENTS:
    stop();
    var swf:MovieClip;
    // always specify datatype
    var bgURL:URLRequest;
    if(page == 1) {
         bgURL = new URLRequest("pages/home.swf");
    else if (page == 2) {
         bgURL = new URLRequest("pages/about.swf");
    else if (page == 3) {
         bgURL = new URLRequest("pages/projects.swf");
    else if (page == 4) {
         bgURL = new URLRequest("pages/experimental.swf");
    else if (page == 5) {
         bgURL = new URLRequest("pages/contact.swf");
    var bgloader:Loader = new Loader();
    configureListeners();
    // now you are ready to load
    bgloader.load(bgURL);
    * Adds listeners.
    function configureListeners():void {
         // NOTE!!! Listeners are added to contentLoaderInfo - not Loader itself
         bgloader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
         bgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
         bgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
    * Removes listeners.
    function removeListeners():void {
         bgloader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoadComplete);
         bgloader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
         bgloader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onLoadError);
    function onLoadComplete(e:Event):void
         // depeneding on the situation
         // you may want to add loaded swf
         // but before if swf exists - you need to remove it
         if (swf && this.contains(swf)) {
              removeChild(swf);
              swf = null;
         swf = bgloader.content as MovieClip;
         addChild(swf);
         // now play
         this.gotToAndPlay("start");
         // dont't forget to remove listeners
         removeListeners();
    function onLoadError(e:IOErrorEvent):void
         // deal with the error
    function onProgress(e:ProgressEvent):void
         // here you update preloader if you have one
         trace("Progress", e.bytesLoaded, e.bytesTotal);
    On a side note, the way you deal with instnatiating URLRequests is not the most efficient or scalable. A better approach would be to keep them in an array and call by index. Note, conditionals are gone.
    var bgList:Array = [
              "pages/home.swf",
              "pages/about.swf",
              "pages/projects.swf",
              "pages/experimental.swf",
              "pages/contact.swf"];
    var bgURL:URLRequest = new URLRequest(bgList[page]);

  • Simple AS3 external swf playing code?

    Hi
    I'm after some REALLY simple code, and am happy to pay someone via Paypal to do this for me.
    I want to have a one frame piece of AS3 code that loads in external swfs from an array.
    I want external swf 1 to play, and when it's finished, swf 1 unloads from memory, and then external swf 2 starts playing and so on through the array.
    When the end of the array is met, it loops back to the first swf and starts again.
    I don't need transition effects or anything like that.
    This is to be used for an offline project, so it's not connected to the web.
    I've been playing with it for a while myself, but can't get this to work.  It should be a simple and quick job for someone out there.  Just load a new swf into the child holder and play.  When that swf's finished playing, dump it, and load in and play the next one.
    Thanks for your help.
    Shaun

    Nothing at this stage - I'm still experimenting to figure out the best way to do it.  I found something like what I want at http://www.flashandmath.com/intermediate/externalclips/ext_clip2.html (without button control though - there's a code addition at the bottom to add in to make the swfs play by themselves).
    The problem with the above example is I can't get any external swfs besides the example ones to play.  I even tried renaming my as3 swfs to clip0 etc, but still nothing.
    If someone can make it for me, and it means I have to add some code to the end of each external swf, if they can include the code to add, I can incorporate it no probs.
    Cheers
    Shaun

  • Dling external .swf files while main movie is playing

    Does anybody know a command to have your flash movie download
    external .swf movies within the "main" movie while playing. I have
    about 8 .swf's that are all linked together but the problem is the
    loading of each one seperatly (kinda lags a bit b4 each movie is
    loaded, because you have to download each and everyone) PLEASE help
    me out I'm working on a big project here at work :yikes: Thank
    you!!

    jsns wrote:
    > Does anybody know a command to have your flash movie
    download external .swf
    > movies within the "main" movie while playing. I have
    about 8 .swf's that are
    > all linked together but the problem is the loading of
    each one seperatly (kinda
    > lags a bit b4 each movie is loaded, because you have to
    download each and
    > everyone) PLEASE help me out I'm working on a big
    project here at work
    > :yikes: Thank you!!
    >
    check help files for details and usage of "loadmovie" and
    "loadmovienum" actions.
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    Happy New Year
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • How can I combine multiple animations. (Play another animation after one has finished with a click?)

    How can I combine multiple animations. (Play another animation after one has finished with a click?) Like a slideshow but with animations. any ideas?

    You can do this by calling up the different edge Animate composition html pages using buttons and an iframe:
    To get a general idea, put this in the body of an html page and insert your own URLs where indicated
    <iframe id="iframeID" src="yourFirstURL" width="640" height="480">
    <p>Your browser does not support iframes.</p>
    </iframe>
    <button onclick='loadIframe("iframeID", "firstAnimURL")'>First Animation</button>
    <button onclick='loadIframe("iframeID", "secondAnimURL")'>Second Animation</button>
    <button onclick='loadIframe("iframeID", "thirdAnimURL")'>Third Animation</button>
    <script>
    function loadIframe(iframeID,url) {
    //alert("Hello");
       document.getElementById("iframeID").src = url;
    </script>
    Peter Small

Maybe you are looking for

  • Spry is undefined, sp2 is null or not an object error in IE

    Hi everyone, I have a problem working with Spry Sliding panels. It is working fine in chrome, safari. But it is not working in IE and FF I am on IE8 and FF3 I also upgraded to the latest version of Spry i.e Spry 1.6.1 The website is in development. H

  • General exception error

    hii members, I am getting this error for bi base run time error: GENERAL EXCEPTION IN DEPLOY TRANSFORMATION FOR OBJECT.               Kindly throw some light on to which part is the error from.

  • How can I include personalization to WLS servlets

    Hello I have WLS 5.1 and WLCS\PS 3.2 How can I personalized servlets which works on WLS 5.1 in the best way? (Some docs on BEA site?) Regards BP

  • TMS configuration

    Hi, I'm in the process of installing solution manager. I've managed to run saprouter & to logon to sapnet. Now i'm having a hard time configurating the TMS. My conf is the following Solution manager & SAProuter are both installed on the same machine.

  • Help using ipod for photos, music, and video

    Guys, I received an IPOD classic 80gig months ago with a college class that I took. I thought it was really neat at the time as I could watch the videos. However, now I'm so glad that it came free with the class and honestly can't understand how anyo