Tobio
Tobio

Reputation: 255

make flash button disappear when playing audio

I have a flash document (Actionscript-3) with play button on top of a image, and an audio is played when the button is clicked. How do I make the play button disappear when it is clicked and audio is playing. The button should reappear after the audio has finished playing.

Upvotes: 0

Views: 557

Answers (1)

Amy Blankenship
Amy Blankenship

Reputation: 6961

in your button click handler:

protected function click_Button(e:MouseEvent):void {
    (e.currentTarget as DisplayObject).visible=false;
    var sound:SoundChannel = yourSound.play(0, 1);
    sound.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
}

protected function onSoundComplete(e:Event):void {
    yourButton.visible = true;
    (e.currentTarget as EventDispatcher).removeEventListener(Event.SOUND_COMPLETE, onSoundComplete);
}

Upvotes: 3

Related Questions