Skip to main content
MathAdor
Participating Frequently
May 15, 2011
Question

Accessing buttons on main stage from inside of a movie clip

  • May 15, 2011
  • 2 replies
  • 636 views

Greetings...

      here is the scenario:

             - I have buttons on main stage, and a swf file which is loaded to scene using a LOADER in AS3

             - this is a website, so the problem rises when user moves its cursor around the page and now  buttons in main stage,

                are still active since they are behind the loaded swf file.

             - i would like to learn, how can i CODE inside the loaded SWF file, to either remove the buttons in main page, or remove

                the event listeners. not sure if my case has anything to do with .Parent or .roo, (I want to access those main stage

                buttons from the SWF file which is loaded)

             - The general case is, i have SWF files loading inside another SWF files, is it possible to access items on each stage from

                inside of loaded SWF files on that specific stage. Similarly i would be interested to learn about accessing main stage from inside

                of movieclips running on stage. how can i access something not in present FLA file yet, in FLA file that is loading the page as SWF.

                Thanks.

This topic has been closed for replies.

2 replies

Ned Murphy
Legend
May 15, 2011

If you load an swf into another using the Loader class, then the Loader itself is the parent of the loaded swf., so MovieClip(parent.parent) might help you to target the timeline that the Loader was born from.  The more proper way to have a loaded file talk to a parent file is thru dispatching events that the parent assigns listeners for after the file has loaded.  Here's a link to a posting that might help explain how to implement this.

http://forums.adobe.com/thread/470135?tstart=120

As for the buttons that you want to disable, you could either use the removeEventListener() method to remove the listeners you have assigned, or you could set their mouseEnabled property to false, or you could set their visible property to false.

MathAdor
MathAdorAuthor
Participating Frequently
May 15, 2011

Amazing....i m reading comments on the link you provided. thanks. i need to educate myself alittle bit about dispatchEvent and other commands explained in the discussion, let me try my best and i will post my codes along with errors in case i fail. Thank you

May 15, 2011

I think this will help you

function btnMC(event:MouseEvent):void {
MovieClip(parent).main_mc.gotoAndStop(1);

or
MovieClip(parent).gotoAndStop("page1");

}

btn.addEventListener(MouseEvent.CLICK, btnMC);

MathAdor
MathAdorAuthor
Participating Frequently
May 15, 2011

Thanks...

i tried the code, still gives me errors, i think your suggestion will work perfectly for the movieclip scenario, i tried to explain my question in a simpler way in another post. Thanks though.