A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Help with AS3:unloading external swf files with mouse click

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    1

    Help with AS3:unloading external swf files with mouse click

    I have external swf files which open in main swf with button click. I want the swf to close on mouse click but having problem with the actionscript. Any ideas about how to do this? here's the code so far:

    var img1Request:URLRequest = new URLRequest ("kelly.swf");
    var img1Loader:Loader = new Loader();
    kelly_mc.addEventListener(MouseEvent.CLICK, clickF);

    function clickF(event:MouseEvent):void{
    img1Loader.load(img1Request);
    img1Loader.contentLoaderInfo.addEventListener(Even t.COMPLETE,loadNowF);
    function loadNowF(event:Event):void{
    container_mc.addChild(img1Loader);
    }
    }

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    put this as the event handler for whatever element you want to click to close the loaded swf
    PHP Code:
    function killSWF(event:Event):void{
    try{
    img1Loader.close();
    } catch(
    e) { };
    img1Loader.unload();
    }; 

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