Copy link to clipboard
Copied
I have a set up where my main time line is keyframed out into labeled sections. In one of the labeled sections I load and SWF file using greensock SWF Loader. In the loaded SWF there is a command where I need to remove/addEventListeners on the main timeline of the flash file out of the loaded SWF.
The set up with "MovieClip(parent.parent.parent.parent)." works for navigation and loading and all other functions. However I get the error "1120: Access of unidetified property" if I want to use a line of code such as this:
//MovieClip(parent.parent.parent.parent).mainNav_buttonsGroup_mc.Applications_btn_mc.removeEventListener(MouseEvent.ROLL_OVER, overHandler_Applications_btn);
Do I need to simply write up this EventListeners again in the loading SWF file (thus repeating them again as they are specified on the main time line already) or there is a better method to it?
appImgBtns_mc.testBtns2_mc.addEventListener(MouseEvent.CLICK, onClick_testBtns2);
function onClick_testBtns2(event:MouseEvent) :void {
/////////
////disabling the button onClick by removeEventListener
//MovieClip(parent.parent.parent.parent).mainNav_buttonsGroup_mc.Applications_btn_mc.removeEventListener(MouseEvent.ROLL_OVER, overHandler_Applications_btn);
//MovieClip(parent.parent.parent.parent).mainNav_buttonsGroup_mc.Applications_btn_mc.removeEventListener(MouseEvent.ROLL_OUT, outHandler_Applications_btn);
//MovieClip(parent.parent.parent.parent).mainNav_buttonsGroup_mc.Applications_btn_mc.removeEventListener(MouseEvent.CLICK, onClick_Applications_btn);
////coloring the button
MovieClip(parent.parent.parent.parent).Applications_btn_timeLine.play();
//Products_btn_mc
//MovieClip(parent.parent.parent.parent).mainNav_buttonsGroup_mc.Products_btn_mc.addEventListener(MouseEvent.ROLL_OVER, overHandler_Products_btn);
//MovieClip(parent.parent.parent.parent).mainNav_buttonsGroup_mc.Products_btn_mc.addEventListener(MouseEvent.ROLL_OUT, outHandler_Products_btn);
//MovieClip(parent.parent.parent.parent).mainNav_buttonsGroup_mc.Products_btn_mc.addEventListener(MouseEvent.CLICK, onClick_Products_btn);
//discoloring the button
MovieClip(parent.parent.parent.parent).Products_btn_timeLine.reverse();
MovieClip(parent.parent.parent.parent).sourceVar_AppPopUpsLoader_fromPrdcts="images/app_images/original/icysophistication_new_tl.swf";
MovieClip(parent.parent.parent.parent).gotoAndPlay("appPopUps_fromPrdcts");
}
You can communicate with the Main timeline by dispatching events from the child swf.
When the child Swf is loaded, dispatch an event, i.e. - dispatchEvent(new Event("DoTimeLineCode"));
Then on your main timeline, listen for the event and execute the functions you want:
MovieClip(root).addEventListener("DoTimeLineCode", mainTimeLineFunctions);
function mainTimeLineFunctions(e:Event):void
{
MovieClip(root).Applications_btn_timeLine.play();
//etc...
}
Chasing down MovieClip(parent.parent.par
Copy link to clipboard
Copied
You can communicate with the Main timeline by dispatching events from the child swf.
When the child Swf is loaded, dispatch an event, i.e. - dispatchEvent(new Event("DoTimeLineCode"));
Then on your main timeline, listen for the event and execute the functions you want:
MovieClip(root).addEventListener("DoTimeLineCode", mainTimeLineFunctions);
function mainTimeLineFunctions(e:Event):void
{
MovieClip(root).Applications_btn_timeLine.play();
//etc...
}
Chasing down MovieClip(parent.parent.parent.parent) has always been a losing battle for me. It's best practice to use event dispatchers and listeners to instantiate "things" from the parent child paradigm.
~Chipleh
Copy link to clipboard
Copied
Thanks, that seems to work. I dont seem to be able to get to the MovieClip(root)
Maybe you can glance at my code and suggest how it has to be specified.
Here is how SWF is being loaded onto the stage. I am using greensock.com SWF loader
var sourceVar_ProductsPopUps:String;//has to be specified only once for the rest of all the buttons so individual SWFs may be loaded into LoaderMax or UILoader
var loaderProductPopUps:SWFLoader;
loaderProductPopUps = new SWFLoader(sourceVar_ProductsPopUps, //the value of sourceVar_ProductsPopUps allows to load mulitple SWFs from the products page.
{ container:holderMovieClip,
"holderMovieClip" is where the SWF loader is placed.
Here is my code from the main time line:
MovieClip(holderMovieClip).addEventListener("DoTimeLineCode", mainTimeLineFunctions);
function mainTimeLineFunctions(e:Event):void{
MovieClip(holderMovieClip).Applications_btn_timeLine2.play();
}
Copy link to clipboard
Copied
This will work:
MovieClip(root).holderMovieClip.addEventListener("DoTimeLineCode", mainTimeLineFunctions);
Another option:
If you want to directly reference the actual Movie Clip, something like this will work:
var holderClip:DisplayObject = MovieClip(root).getChildByName("holderMovieClip");//assumes there is a Movie Clip on your stage named "holderMovieClip"
if(holderClip != null)//verify it exists and if it does. add the listener
{
holderClip.addEventListener("DoTimeLineCode", mainTimeLineFunctions);
}
Either one of these should "make it go"
Hope that helps,
~Chipleh
Copy link to clipboard
Copied
I do have "holderMovieClip" on stage. SWF's are being loaded in there.
_____________________________________________________________________
•When I use the line:
MovieClip(root).holderMovieClip.addEventListener("DoTimeLineCode", mainTimeLineFunctions);
•Then I get an error:
TypeError: Error #1010: A term is undefined and has no properties.
_____________________________________________________________________
When I use this set up:
var holderClip:DisplayObject = MovieClip(root).getChildByName("holderMovieClip");//assumes there is a Movie Clip on your stage named "holderMovieClip"
if(holderClip != null)//verify it exists and if it does. add the listener
{
holderClip.addEventListener("DoTimeLineCode", mainTimeLineFunctions);
}
_____________________________________________________________________
I have no errors but time line does not play
Maybe I missed the part how I have to listed to the event on the main time line?
Here is the code from the main time line in its entirety:
From the main time line:
var Applications_btn_timeLine2:TimelineMax = new TimelineMax({timeScale: 1.75, paused:true});
Applications_btn_timeLine2.appendMultiple([//blur and coloration inside the button
TweenMax.to(mainNav_buttonsGroup_mc.Applications_btn_mc.maskedBlackIN_Applications.blkBlurredApplications_insideMask, .25, {autoAlpha: .4, scaleY:1.3, scaleX:2 }),
TweenMax.to(mainNav_buttonsGroup_mc.Applications_btn_mc.maskedBlackIN_Applications.whiteUnder_blkBlurredApplications_insideMask_mc, .5, {autoAlpha: 1, tint:0x00ccff })
],
.05, //offset number, i.e. how long it waits before to start
TweenAlign.START,//tweens start times are aligned if TweenAlign.START, or TweenAlign.SEQUENCE so they start one after another
0.12);
var holderClip:DisplayObject = MovieClip(root).getChildByName("holderMovieClip");//assumes there is a Movie Clip on your stage named "holderMovieClip"
if(holderClip != null)//verify it exists and if it does. add the listener
{
holderClip.addEventListener("DoTimeLineCode", mainTimeLineFunctions);
}
//MovieClip(root).holderMovieClip.addEventListener("DoTimeLineCode", mainTimeLineFunctions);
function mainTimeLineFunctions(e:Event):void{
MovieClip(holderMovieClip).Applications_btn_timeLine2.play();
}
and from the loaded SWF:
appImgBtns_mc.testBtns2_mc.addEventListener(MouseEvent.CLICK, onClick_testBtns2);
function onClick_testBtns2(event:MouseEvent) :void {
dispatchEvent(new Event("DoTimeLineCode"));
MovieClip(parent.parent.parent.parent).sourceVar_AppPopUpsLoader_fromPrdcts="images/app_images/original/icysophistication_new_tl.swf";
MovieClip(parent.parent.parent.parent).gotoAndPlay("appPopUps_fromPrdcts");
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now