A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Loading an swf from another swf (replacing)

  1. #1

    resolved [RESOLVED] Loading an swf from another swf (replacing)

    Simple AS3 question from a rookie...

    I have a main shell swf file that has two buttons on it that should each launch/load their respective swf files (tool1, tool2). These should essentially replace the main swf file. Also, I have a button on tool1 & 2 that should bring you back to the main menu. All these files are then compiled into an exe. Seems easy enough, but I'm not entirely sure where to start.

    So far I have:
    import flash.display.*;
    import flash.net.URLRequest;

    tool1_btn.addEventListener(MouseEvent.CLICK, gotoTool1);

    function gotoTool1 (e:MouseEvent):void{
    Loader(this.parent).load(new URLRequest("tool1.swf"));
    }


    Any insight would be greatly appreciated.

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,764
    There's no replacing one SWF with another in AS3. After the new SWF has been loaded you have to add it to the display list using addChild and remove the calling SWF with removeChild. Make sure that all the event listeners and references to the original SWF have been cleaned up before you try to remove it or it won't be garbage collected.
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  3. #3
    Finally got around to this and used your advice.
    Took some finagling since I had no idea what I was doing, but got it to work.
    Thank you.

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