Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Swfs playing in a sequence (AS3)

    Hi, I am building a movie which has more than one swf. The swfs are called movie1, movie2, etc.

    I want to load these swfs into a main swf that will play them in a sequential order. Such as when movie1 is finished, movie2 begins, and when movie2 stops, movie3 begins etc. The swfs themselves have AS3 and multiple frames in them, one with a menu-like interface, so it's not just a case of importing them.

    So in short, two or more swfs playing in sequential order from a main swf.

    I've asked around forums and the best I've got so far is

    var request:URLRequest;
    var loader:Loader;
    var myMovies:Array = ["loader.swf", "movie2.swf"];
    var movieNum:int = 0;

    function loadSWF():void
    {
    request = new URLRequest(myMovies[movieNum]);
    loader = new Loader();
    loader.load(request);
    stage.addChild(loader);
    stage.addEventListener(Event.ENTER_FRAME, eFrame);
    }

    function eFrame(e:Event):void
    {
    if (loader.content.currentFrame == loader.content.totalFrames)
    {
    stage.removeChild(loader);
    stage.removeEventListener(Event.ENTER_FRAME, eFrame);
    request = null;
    loader = null;
    movieNum++;
    loadSWF();
    if (movieNum >= myMovies.length())
    {
    movieNum = 0;
    }
    }
    }

    loadSWF();
    However the (loader.content.currentFrame == loader.content.totalFrames) line throws up a 1119 error in that it is 'possibly undefined' when I have declared the variable beforehand.

    I can't seem to find any resources on this. Is it actually possible? I've worked on it for weeks and everyone seems completely stumped when I ask them

  • #2
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #4
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile This one works for me

    var request:URLRequest;
    var loader:Loader= new Loader();
    stage.addChild(loader);


    var myMovies:Array=["ani1.swf","ani2.swf", "ani3.swf"];
    var movieNum:int=0;
    var mcExternal:MovieClip;

    function loadSWF():void {
    request=new URLRequest(myMovies[movieNum]);

    loader.load(request);

    // waiting for the loader to be ready
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplet);


    }


    function onComplet(e:Event):void {

    loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onComplet);
    trace("ready to call eFrame");
    stage.addEventListener(Event.ENTER_FRAME, eFrame);

    }


    function eFrame(e:Event):void {
    mcExternal=loader.content as MovieClip;
    var current:int=mcExternal.currentFrame;
    var total:int=mcExternal.totalFrames;

    trace(current);
    trace(total);


    if (current >= total ) {
    trace("Load next swf ");
    loader.unloadAndStop();

    mcExternal=null;
    movieNum++;
    stage.removeEventListener(Event.ENTER_FRAME, eFrame);
    request=null;
    loadSWF();


    if (movieNum>=myMovies.length) {
    movieNum=0;
    }
    }

    }

    loadSWF();

  • #5
    New to the CF scene
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    loading swf files in sequence

    Hi everyone,

    I'm new to Flash and was having a similar problem -- trying to figure out how to play a series of swf files in a master file so that one file strats playing automatically after the other is done. I tried the code above, but get the following error:

    Load next swf
    TypeError: Error #2007: Parameter url must be non-null.
    at flash.display::Loader/_load()
    at flash.display::Loader/load()
    at labconmaster_fla::MainTimeline/loadSWF()
    at labconmaster_fla::MainTimeline/eFrame()


    What am I missing? I'm working in AS3 in Flash CS4.

    Thanks

  • #6
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just used the same code and got the same error. I fixed it by adding an else to the second if statment in the last function.at the end and moving the loadSWF(); inside.

    function eFrame(e:Event):void {
    mcExternal=loader.content as MovieClip;
    var current:int=mcExternal.currentFrame;
    var total:int=mcExternal.totalFrames;

    trace(current);
    trace(total);


    if (current >= total ) {
    trace("Load next swf ");
    loader.unloadAndStop();

    mcExternal=null;
    movieNum++;
    stage.removeEventListener(Event.ENTER_FRAME, eFrame);
    request=null;


    if (movieNum>=myMovies.length) {
    movieNum=0;
    }else{
    loadSWF();
    }
    }

    }


  •  

    Posting Permissions

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