开发者

make flash button disappear when playing audio

开发者 https://www.devze.com 2023-03-27 12:39 出处:网络
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

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

精彩评论

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