开发者

Adobe Flash CS3 sound in movieclip

There's an animation (MovieClip) in my scene. There's a sound accompanying animation. I inserted it into the first frame of the animation. I want this animation to be i开发者_开发技巧nactive initially. I plan to activate it when some button is pressed. I don't know how to set it "inactive" from within Adobe Flash workspace, so I just put in constructor of my scene:

MovieClip(getChildByName("MyAnim")).stop();

By it does not prevent that sound to start playing when my scene appears!

How do I manage it?


In my experience, it usually isn't a good idea to insert sounds directly onto the timeline in flash. I strongly advice to import the .mp3 into the Flash program and play it by code using the AS3 Sound class.

EDIT: This way, the sound won't play until you use the Sound Class .play() method, which you could do at the beginning of your animation on the timeline OR from the button that activates it.

Here is a nice Republic of Code tutorial giving you a step by step on how to play a Sound file using the AS3 Sound Class.


Put the sound on frame two in your movieclip. Then go to that frame when you click the button.

private function onButtonClick(event : MouseEvent) : void
{
     mySoundClip.gotoAndStop(2);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜