简体   繁体   中英

AS3 loading external swf on button click

In AS3 (Flash), I want an external swf-file to load when I click a specific menu button. I also want the swf to disappear when I click another button, so that another swf can load. This code shows my swf, but it just "loops". And also it covers my menu (on the top of the page) so I can't click anywhere. What could I change in the code to fix this?

var loader_mc : Loader = new  Loader();
   addChild(loader_mc);

bilder_btn.addEventListener(MouseEvent.CLICK,  buttonClick)
function  buttonClick(e:MouseEvent):void
{
     try{
loader_mc.unloadAndStop();
} catch(e:Error) {
}
      var urlRequest : URLRequest = new  URLRequest("flickr.swf");
      loader_mc.load(urlRequest);
}
  1. Change loader_mc 's X and Y so that the loaded SWF does not cover your menu.
  2. You could do better with reinitializing that loader_mc to load another SWF, that is, create a new Loader() , removeChild() the old loader, addChild() the new one, then load.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM