|
Adding Sound
to the Arrow
The Symbol Linkage Properties dialog-box appears.
{Click} Export this symbol and input a name for the Symbol in the Identifier field. This is the name that we will use in ActionScript to use activate this sound. In this case, use the name drop.
Next, select OK. Now were ready to add the script to trigger the sound into the button. Select the Instance of button.empty over clip.arrow. Thus far we have: on
(press) { Below the statement
xc._rotation+=180 well add the following three (3) statements: The complete code set for the button this far should appear as follows: on
(press) { Lets take a look at the three (3) statements which activate the sound. clickSound = new Sound(this); Our first step, instantiate the Sound Object (or Class if you prefer). Were going to call our Instance of the Sound Object clickSound. The argument this tells Flash that we are making an Instance of the Sound Object on the current Timeline. If we were to leave this argument blank, the Sound Object clickSound would have control of any sounds we attach to it movie wide. clickSound.attachSound("drop") We use the attachSound method to specify which sound we wish to control in our object. We gave the Sound Symbol Switch Small Plastic an Identifier called drop. Hence we refer to drop in the argument of the attachSound method. clickSound.start(); Finally, we use the
start method to tell the sound in our clickSound Sound Instance to start
playing. Arguments include how many seconds into the sound clip itself
the sound begins and how many times we want the sound to loop. We just
want the sound to play once, completely through, each time the user {Clicks}
the arrow button so we leave the arguments blank. |