OK, spent days now trying to grasp the concept of event listeners in AS3. No luck yet.
So I’ll use a simple setup to maybe get some one to explain how to use these ■■■■ listeners.
I have a Document Class (Main.as)
I have a MainMenu Class (MainMenu.as)
I have a ContentViewer Class (ContentViewer.as)
I have a ContentScroller Class (ContentScroller.as)
And I could have had a thousand more for that matter …
- In the Main Class I add instances of all the different classes and add them to the stage.
Each instance places them selves on stage based on values in their respective constructors.
var myMainMenu:MainMenu = new MainMenu();
addChild(myMainMenu);
… and so forth for all other instances.
Now, all Classes have ShowMe() and HideMe() methods using a Tween to fade the alpha of it self either up or down.
function ShowMe():void
{
Tweener.addTween(this, {alpha: 1, time: .25, transition: "easeOutQiunt"});
}
function HideMe():void
{
Tweener.addTween(this, {alpha: 0, time: .25, transition: "easeOutQiunt"});
}
What I’d like to achieve is, when I click the ContentViewer (or a button on this), I’d like to tell the MainMenu to either show or hide itself (maybe based on its own state).
My question is: How do I trigger the method on MainMenu (that tells it to either hide or show itselt) from the ContentViewer instance?
Any help on clearing a basic design as this would be appreciated. Or may I’ve just got the whole OOP idea screwed up.