I have to access a function in child swf from parent swf. This child swf gets loaded into a canvas object in parent.swf. Everything works fine but I’m unable to call any function that was in child.swf.
My code is
var swf1:SWFLoader = new SWFLoader();
swf1.source = "CHILD.swf";
can.addchild(swf1);
I read on google and then I tried this in parent.swf’s code
var myrequest:URLRequest = new URLRequest("CHILD.swf");
var myloader:Loader = new Loader();
myloader.load(myrequest);
canvas.addchild(myloader);
Now this one throws up a runtime error TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@5934b01 to mx.core.IUIComponent.
I also tried this
var myrequest:URLRequest = new URLRequest("CHILD.swf");
var myloader:Loader = new Loader();
myloader.load(myrequest);
var uic:UIComponent = new UIComponent();
uic.addChild(myloader);
canvas.addChild(uic);
But in this case my swf does not show up at all and there are no runtime errors too!
How do I resolve this error and how do I then access the function in child.swf?
PLEASE HELP GUYS…