Flash code help with addEventListener actionscript 2.0
Alright here's the setup.
actionscript 2.0
I have an animated mirror with sound. (Mmirror)
There is a button to toggle the mirror visible or not. (mirrorBTN)
The button is inside a menu movieclip. (BelleMenuItems)
The animation inside the mirror movieclip starts on frame 2. frame 1 has a stop.
Here's the problem.
(this was after I heard the sound playing with the mirror invisible.)
when you toggle the movie visible its fine, I set it to gotoAndPlay frame 2, and looping back to 2. with a stop on 1. but when you toggle the movie invisible, the sound still plays, because its technically still playing the animation movieclip you just cant see it.
I'm trying to add an event listener that knows when the movie clip is visible and invisible, and will tell it to go to the correct frame to start or stop the animation.
It wouldn't be a problem if there was no sound, but I think the sound enhances the animation.
here's the code i pulled out of the flash help to modify:
Code:
function eventResponse(eventObject:EventType):void
{
// Actions performed in response to the event go here.
}
eventTarget.addEventListener(EventType.EVENT_NAME, eventResponse);
I dont really understand what all of these things mean, as i'm a self taught actionscriptor, still learning.
Here's what I've modified. It may be completely wrong....I haven't tried it because I know it wont work since I haven't changed all the variables to what they should be. I just don't know what they should be.
Code:
// mirror animation start code
function ManimON(eventObject:_visible=true):void
{
_root.Mmirror.gotoAndPlay(2);
}
_root.BelleMenuItems.mirrorBTN.addEventListener(_visible=true.EVENT_NAME, ManimON);
// mirror animation stop code
function ManimOFF(eventObject:_visible=false):void
{
_root.Mmirror.gotoAndPlay(1);
}
_root.BelleMenuItems.mirrorBTN.addEventListener(_visible=false.EVENT_NAME, ManimOFF);
This is the only solution I could think of, but if there is an easier one, please share.