Hey there,
i've been searching the net and slowly ripping my hair out for days for this exact situation.
i have a main SWF that loads another SWF(a scene). once a certain button is clicked in the scene SWF, i need the parent SWF to do an action . which is exactly what this thread is about. However, i have followed all of the steps (i want to achieve this through events rather than parent.parent path)
i can fire off a custom event inside the scene SWF, listen for it and catch it no problem. but i CANNOT get the main SWF to listen to the event and catch it. i cant even access the function in the parent SWF through the parent.parent path
i even created a custom event and still nothing seems to work.
i've also tried:
MovieClip(_loader.content).addEventListener("my event", eventHandler);
- where "my event" is fired from the scene SWF once a button is clicked:
dispatchEvent(new Event("my event"));
- and that got me nowhere
this is what my Container class looks like (the parent)
public class Container extends MovieClip
{
private var _loader:Loader;
private var _loading:Loader_MC;
private var _path:String = "SWF/Scene.swf";
public function Container()
{
startLoad();
}
private function startLoad():void
{
_loader = new Loader();
_loader.load(new URLRequest(_path));
_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showLoading);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
}
private function showLoading(e:ProgressEvent):void
{
_loading = new Loader_MC();
_loading.x = stage.stageWidth * 0.5;
_loading.y = stage.stageHeight * 0.5;
addChild(_loading);
}
private function loadComplete(e:Event):void
{
removeChild(_loading);
_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, showLoading);
_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, startLoad);
addChild(_loader);
MovieClip(_loader.content).addEventListener(ResponseEvent.CONTROL_SCENE, eventHandler, false, 0, true);
}
private function eventHandler(e:ResponseEvent):void
{
trace("heard the event!!!!!");
}
}
please shed some light on this. i am at a loss. i know its something small...
much appreciated!
Serge.