![flash actionscript 3.0 play sound effect flash actionscript 3.0 play sound effect](http://markbennison.com/media/1173/ss-0605-export.jpg)
This variable keeps track of whether you want to play or stop the soundįunction fl_ClickToPlayStopSound(evt:MouseEvent):void Keep the quotation marks ("").īutton_1.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound) Replace "" below with the desired URL address of your sound file. Then we will see the following sample codeĬlicking on the symbol instance plays the specified sound.Ĭlicking on the symbol instance a second time stops the sound.ġ.
FLASH ACTIONSCRIPT 3.0 PLAY SOUND EFFECT CODE
Animate will create an instance name before applying the code sample. The selected symbol requires and instance name. Note: Here we are using Basic layout settings for the Animate interfaceĠ.6 From left hand side tool bar, Click on Rectangle Tool (A Rectangle icon)Ġ.7 Draw a simple square or rectangle on the canvasĠ.8 Right Click on the shape we have drawn, Click on Convert to Symbol…Ġ.9 Make sure we change the Type to ButtonĠ.10 Click on Advanced to expand, Check Export for ActionScript, Click on OK buttonĪ definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export.Ġ.12 Make sure from top left corner, the Scene 1 is selected, if not, Click on itĠ.13 From top menu bar, Click on Window -> ActionsĠ.14 From Actions window, Click on the Code Snippets (The icon/button) from top right of the Actions windowĠ.15 From Code Snippets window, Click on ActionScript -> Audio and Video -> Click on Click to Play/Stop Sound 3 Method 3 – Using an embedded mp3 file (Import the mp3 file into the Library)įirst we need to create a ActionScript 3.0 canvas in Animate, then draw a simple shape, set it to a button, bring up the ActionScript panel and load the sample Play/Stop audio code, then we will use different methods to play the audio file from different sources with minor code change.2 Method 2 – Using a mp3 file placed in a folder.We want to play music/sound/audio file in Animate (using ActionScript 3.0) in different ways, using a mp3 file from a url or using a mp3 file from a local folder or using a mp3 file embedded into the flash/swf etc.