Flash Tutorials - Herong's Tutorial Examples - Version 3.01, by Dr. Herong Yang
Sound.sc - Adding Sound to Animation
This section provides a tutorial example on create a simple Flash animation with sound using SWFC script with '.sound' and '.play' commands.
If you are interested to add sound to an animation, you can:
Here is my tutorial example, sound.sc, which is based on frame.sc with an MP3 music added in the animation:
#- sound.sc #- Copyright (c) 2014, HerongYang.com, All Rights Reserved. # .flash bbox=150x350 background=gray fps=12 .circle greenLight r=50 line=5 color=black fill=green .circle yellowLight r=50 line=5 color=black fill=yellow .circle redLight r=50 line=5 color=black fill=red .sound mySound "Music_Sample.mp3" #- Settig up the default frame which is frame 1 .put greenLight x=25 y=225 .play mySound loop=1 #- Making changes on frame 25 .frame 25 .del greenLight .put yellowLight x=25 y=125 #- Making changes on frame 37 .frame 37 .del yellowLight .put redLight x=25 y=25 #- Making changes on frame 61 .frame 61 .del redLight .put greenLight x=25 y=225 .end
Compile and generate the HTML code:
C:\herong>\local\SWFTools\swfc sound.sc -o sound.swf wav_read: not a WAV file readMP3: skipping ID3 tag (10+4086 bytes) readMP3: invalid header 54 41 47 43 "Music_Sample.mp3" seems to work as a MP3 file... C:\herong>\local\SWFTools\swfdump -E sound.swf > sound.html
Remember to delete the extra "loop" parameter in sound.html and change the "loop" parameter value to "true". The you are ready to play sound.html.
I have included the HTML code here on this page.
If you are reading the Web version of this book,
you should be able to see the animation played.
Otherwise, you will see a static image.
Last update: 2014.
Table of Contents