Hi,
I have a main.swf file. From that file I am accessing the external.swf file which is an external file.
Now, how can I write code on my main.swf file for the button which is on my external.swf file?
Activities.MainPanel.close_btn.addEventListener(MouseEvent.CLICK, btnClickClose);
Activities.MainPanel.close_btn (This buttons is actually on external.swf file, but I want to write code on main.swf file to execute it on external.swf) how can I control one swf button on other swf file?
Thanks.
Depending on your setup you have a few options.
Here's some example code that you should be able to adapt to your needs.
// create a new loader object instance...
var loader:Loader = new Loader();
// make the download request...
var request:URLRequest = new URLRequest("external.swf");
// add a complete event listener to the loader
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
// start the actual loading process...
loader.load(request);
// create a new empty movieClip instance, you will put the loaded movie into this movieClip once its loaded
var externalMovie:MovieClip;
// this function is called when the download has finished and the file is ready to use...
function completeHandler(event:Event):void {
// set the contents of the loaded movie to the new empty movieClip...
externalMovie = MovieClip(event.target.content);
// add this new movie to the display list...
addChild(externalMovie);
}
Now you can refer to the loaded movie with the instance name "externalMovie". So if, for instance, you want to address a button in the loaded movie, you could write something like this on the main timeline:
externalMovie.addEventListener(MouseEvent.CLICK, btnClickClose);
function btnClickClose(event:MouseEvent):void {
}
North America
Europe, Middle East and Africa
Asia Pacific