| In this tutorial, we will add some ActionScript that will tell Flash CS5.5 to play a sound file when the reader clicks on one of the Christmas ornaments. We have the option of using the same sound file for all three ornaments or "attaching" a different sound file to each ornament. As always, this decision will depend on all the other elements added to your app and the final file size.|
We already have the ornaments on the stage and they are animated to sway. This animation is a Tween that plays inside each ornament movie clip. Because we have added the ornament movie clips to Frame 1 of the Timeline, the animation will start when the app loads and will continue until we remove the ornament movie clips from the stage.
We also want our readers to be able to click on the ornaments and play a jingle sound file. Although the ornaments are movie clips and not buttons, we will use ActionScript to tell Flash that our movie clips will also function as buttons.
Although Flash accepts several sound file formats, it's best to covert the file to mp3 format for mobile apps. Once you have the file in mp3 format, you are ready to import it into your project.
Open the storybook project file.
In the Library Panel you will find the imported sound file. We will be controlling the sound file with ActionScript. In order to do this we need to make a change to the file by linking it to a class.
2. Right-click on the sound file and choose Properties. In the Sound Properties dialog box, click the ActionScript tab. Check the box next to Export to ActionScript.
3. You will notice that the name of the sound file appears in the Class text box. Remove the file extension .mp3. This sound file now has a Class linked to it with the same name.
Join us in the Digital Art and Design forum. | Join us in the Flash forum.