How to access functions on my main SWF from my external SWF?
Hello can someone help me how to access functions on my main SWF file from a loaded SWF file?
Hello can someone help me how to access functions on my main SWF file from a loaded SWF file?
Forget about using parent. Dispatch an event instead.
btn3.addEventListener(MouseEvent.CLICK, btnClickHandler);
function btnClickHandler(e:MouseEvent):void {
dispatchEvent(new Event("categoryClick");
}
In your main swf, listen for the complete event on the Loader.contentLoaderInfo.
In the complete event handler, add a listener for the categoryClick (or whatever you chose to call it) event on the loaded swf.
// event handler triggered when external swf is loaded
function loaderCompleteHandler(event:Event) {
(event.currentTarget.content as MovieClip).addEventListener("categoryClick", categoryClickHandler);
}function categoryClickHandler(event:Event):void {
trace("category button clicked in loaded swf");
}
And remember, every time you use root or parent, god kills a kitten.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.