Contents

Controlling the Timeline Adding JavaScript

Adding Audio

This tutorial assumes you have a basic understanding of this software.

Create a new movie. Add a sound to the library, this example uses Beep.mp3.


Adding Audio 1

Click to save this sound to your computer.


Add a button to the library and change the text to beep.


Adding Audio 2

Adding Audio 3

Drag the button onto the editor.


Adding Audio 4

Adding Audio 5

Select the button in the library and change the 'On Click' script to:



SoundPlay("Beep",false);

Click 'Play' to test the button. It should beep when you press it.


Play Play

Adding Audio 7

Adding audio to the timeline.

Create a new movie and add the Beep.mp3 sound to the library again. This time create any 20 frame animation you like. We've added a regular shape that moves from left to right.


Sound Sound

Adding audio to the timeline. 8

Click the menu for Beep and choose 'Add To Timeline'.


Adding audio to the timeline. 9

The sound is added to the timeline. A play symbol shows that the sound will be played at this frame. You can change the properties of the frame so that the sounds loops or stops.

Note: The sound will start playing from the beginning, even if it's already playing.


Adding audio to the timeline. 10

Click 'Play' to test the Movie. The animation will play and the sound will play every time if passes frame 0.


Play Play

Adding audio to the timeline. 11

Adding background music.

Create a new movie like the last example. This time add a long sound, we use JazzLoop.mp3 in this example. Again create any 20 frame animation you like.


Sound Sound

Click to save this sound to your computer.


Adding background music. 12

In the properties for the sound in the timeline, choose 'Loop'.


Adding background music. 13

The sound is longer than the duration of the movie. When you play the move, notice that the sound restarts every time the movie passes frame 0.

To solve this problem. In the movie properties, turn off 'Loop'


Adding background music. 14

Then set the 'On End' script to:



GotoAndPlay(1);

Click 'Play' to test the Movie. The animation will play and the sound will play and loop. When the end of the movie is reached, it returns to frame 1 avoiding the sound in frame 0, so the music doesn't restart.


Adding background music to the iPhone and iPad.

It is currently impossible to play sounds on the iPhone and iPad without user interaction. This means a button needs to be pressed to play a sound. However, once a sound has been played, the sound will play again without any other user interaction being required.

To solve this problem, create a new movie, add the JazzLoop.mp3 sound and a button. Change the text of the button to Start and add it to the editor at frame 0.


Adding background music to the iPhone and iPad. 16

Turn off 'Auto Play' in the movie properties.


Adding background music to the iPhone and iPad. 17

Set the 'On Click' script of the button to:



SoundPlay("JazzLoop",true);
GotoAndPlay(1);

When the movie plays, it waits for the button to be pressed before it continues to frame 1. The music will then play in the background on a loop.


Controlling the Timeline Adding JavaScript