Reputation: 1813
I have a class where i create my navigation bar. Then i have created a movieclip on stage, not with AS. In this movieclip is on every frame a different content.
Now i want to pass a number from the navigation class to my movieclip on stage. So i can call "movieclip.gotoAndStop(number)" from an actions layer. But i dont know what the easiest solution would be.
I have this problem because i switch from one menu to another. And the new menu is linked with an external class. So i have already a lot of code on my stage and i do not want to change that.
greets Max
Upvotes: 0
Views: 166
Reputation: 2786
You can use events (you can read about them here, at adobe.com livedocs, and last is probably better place to start). First you need to add event listener to your movieClip:
movieclip.addEventListener(YourEvent, eventHandler);
and than in navigation bar dispatch event:
dispatchEvent(YourEvent);
The system is pretty easy, you dispatch event in one place and listen it in other. The complication could be in listening event, because you can dispatch them only up or down, So in a case when you want to dispatch event from a child of some MoviClip, to the child of other MovieClip you probably will need to dispatch a bubble event to your root object, and there redispatch it back to all children. But it depends on you architecture, how you should build system of event listners and event dispatchers.
Also I usually create MyEvent classes for every type of specific events that i use, so i can send different variables in event, and it helps to read the code in the future.
Upvotes: 1