开发者

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 aud开发者_StackOverflow中文版io has finished playing.


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜