|
-
Sound On/Off Button in Movieclip HELP!!
Hey everyone I've got a real simple AS2 question for you pros!
I'm trying to make a button that when clicked executes a sound clip and plays all the way through. Also, if the button is clicked while the sound is still playing the sound needs to stop. I have no problem getting this to work using Adobe's tutorial.
They have me first place this code in the first frame:
my_sound = new Sound();
my_sound.attachSound("bubble_01sound");
play();
Next I create two buttons, an on and an off which are placed separately in the second and third frames respectively. Code is applied directly to the buttons.
The on button:
on (release) {
_root.my_sound.start(0,1000);
_root.gotoAndStop("stop");
}
The off button:
on (release) {
_root.my_sound.stop();
_root.gotoAndStop("play");
}
Finally, I name the 2nd frame "play" and 3rd frame "stop" and add stop(); to both frames. Oh I also set up the linkage so that the sound's identifier is "bubble_01sound".
This is all well and good however, here's the rub. Unlike their example which takes place in the main timeline, my button needs to bob up and down. So I put everything from the tutorial in a movieclip and on the main timeline animate the movieclip as I like. When this plays the button does not play sound. I took this as the initial sound code not being activated because its in the movieclip. If I take the sound code out of the movieclip and place it in the first frame of the main timeline, the button does play sound but the stop function does not work. I can keep clicking the button which repeats the sound on top of the already playing sound.
So it seems to me there are three options. One, I need to find a way for the sound code to be activated when its seated in the movieclip. Or two, with the sound code in the main timeline, I need a way for the on/off buttons to reference the code which is one level up in the main timeline. Or the third option would be that I'm completely wrong... I'd put my money on the third option.
So if anyone can figure out how I can have this button work properly while seated in a movieclip, I would greatly appreciate it, thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|