A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Should be simple but I can't work it out. Help Please

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    3

    Should be simple but I can't work it out. Help Please

    Hi and thanks in advance for any help as this is driving me crazy!

    I have a Flash file with 5 scenes. On scene 4 (EGT) I have a button which when clicked goes to Scene 5 (EGTvideo). On Scene 5 I have an exported SWF which loads using the code below:



    //This creates a new instance of the loader object.
    var my_Loader:Loader = new Loader();

    //This creates a new instance of the URLRequest object that contains the
    //path to the external SWF.
    var my_url:URLRequest=new URLRequest("Ellie Goulding Album Trailer Completed 1024x768.swf");

    //These listeners detect when the file has finished loading, and if the
    //correct file is loaded.
    my_Loader.contentLoaderInfo.addEventListener(Event .COMPLETE, finishLoading);
    my_Loader.contentLoaderInfo.addEventListener(IOErr orEvent.IO_ERROR, errorHandler);

    //The load method then loads the SWF file into the loader object.
    my_Loader.load(my_url);

    //This function adds the external SWF to the stage.
    function finishLoading(loadEvent:Event) {
    addChild(loadEvent.currentTarget.content);
    }

    //This function displays a message if the file is not found.
    function errorHandler(errorEvent:Event):void {
    trace("file missing");
    }


    All I want is for when the SWF ("Ellie Goulding Album Trailer Completed 1024x768.swf") finishes, it closes that scene and goes back to the start of the previous scene.

    I just cant work out the code to do it and I have been trying now for nearly 2 days!

    Any help would be great. Thanks.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Use [code] tags to post code.

    None of that code is involved in what happens when the loaded swf completes. That's all about loading it in the first place.
    I would expect that you'd have to URLEncode your url, though I'm not 100% certain of that. Spaces are not allowed in urls, so replace them with "%20". Though if it's already loading, forget that.

    I'd have the loaded swf dispatch an event at the end, and listen for that event in the loading swf. Then do whatever you need to in the listener.

    If you cannot change the loaded swf, then you can add an ENTER_FRAME listener to it that checks whether it is on its last frame, and if so, do whatever you need to.

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