A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Back button to reload main swf

  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    36

    Post Back button to reload main swf

    My main swf loads other swf's via this timeline code:

    var req:URLRequest = new URLRequest("scene1.swf");
    var loader:Loader = new Loader();

    loader.load(req);
    addChild(loader);

    Does anyone have AS3 code for a button click to take me back to the main swf (at a particular frame label?) Thx!!

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Assuming the button exists in the outer swf, you would use something like this:

    PHP Code:
    function escapeChildSwf(e:Event null):void{
        
    removeChild(loader);
        
    loader.unload();
        
    gotoAndPlay('someFrame');

    If the button is inside the child swf, you'll need to dispatch a custom event out of their like so:

    PHP Code:
    childBtn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void{
        
    dispatchEvent(new Event('killMe'));
    }); 
    And listen to that event from the parent swf:

    PHP Code:
    loader.content.addEventListener('killMe'escapeChildSwf); 
    Please use [php] or [code] tags, and mark your threads resolved 8)

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