SchmackLab
January 30th, 2009, 10:36 AM
I have a Main timeline with a play button on it. From this main timeline I load in a movieclip. From that movieclip I load in another movieclip. I now have a main timeline with a loaded clip that has another loaded clip nested within it. I want to use the play button on the main timeline to play the topmost loaded clip.
To do this I am trying to dispatch an event (bubble is set to true) that can be picked up by the topmost clip to run an event that will make it play.
The problem I am having is that I do not know how to reference the timeline when listening for the dispatched event.
Can anyone help please?
Here is the code in the main Timeline
var myTimeline = this as MovieClip;
trace(myTimeline);
var _uniMenu:String;
var _imageLoad1:Loader = new Loader();
var _screenLoadY:Number;
var _screenLoadX:Number;
var _imageReq:URLRequest = new URLRequest("laoder1.swf");
_screenLoadY = 0;
_screenLoadX = 0;
load1_btn.addEventListener(MouseEvent.CLICK, onClickLoad1);
function onClickLoad1(event:MouseEvent):void
{
_imageLoad1.load(_imageReq);
addChild(_imageLoad1);
_imageLoad1.x = _screenLoadX;
_imageLoad1.y = _screenLoadY;
_uniMenu = "load1";
}
stop_btn.addEventListener(MouseEvent.CLICK, onClickStop);
function onClickStop(event:MouseEvent):void
{
if (_uniMenu == "load1")
{
dispatchEvent(new Event('load1Stop', true));
}
}
Here is the code in the top most loaded clip.
myTimeline.addEventListener("load1Stop", onClickStop);
function onClickStop(event:Event):void
{
stop();
}
To do this I am trying to dispatch an event (bubble is set to true) that can be picked up by the topmost clip to run an event that will make it play.
The problem I am having is that I do not know how to reference the timeline when listening for the dispatched event.
Can anyone help please?
Here is the code in the main Timeline
var myTimeline = this as MovieClip;
trace(myTimeline);
var _uniMenu:String;
var _imageLoad1:Loader = new Loader();
var _screenLoadY:Number;
var _screenLoadX:Number;
var _imageReq:URLRequest = new URLRequest("laoder1.swf");
_screenLoadY = 0;
_screenLoadX = 0;
load1_btn.addEventListener(MouseEvent.CLICK, onClickLoad1);
function onClickLoad1(event:MouseEvent):void
{
_imageLoad1.load(_imageReq);
addChild(_imageLoad1);
_imageLoad1.x = _screenLoadX;
_imageLoad1.y = _screenLoadY;
_uniMenu = "load1";
}
stop_btn.addEventListener(MouseEvent.CLICK, onClickStop);
function onClickStop(event:MouseEvent):void
{
if (_uniMenu == "load1")
{
dispatchEvent(new Event('load1Stop', true));
}
}
Here is the code in the top most loaded clip.
myTimeline.addEventListener("load1Stop", onClickStop);
function onClickStop(event:Event):void
{
stop();
}