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.

Table of Contents

 About This Book

 Introduction of Adobe Flash

 Adobe Flash Player Plugin for Firefox

 Adobe Flash Player Plugin for Chrome

 Adobe Flash Player Plugin for Safari

 Adobe Flash Player ActiveX for IE

 Using "object" Elements for Flash Files

 Using "embed" Elements for Flash Files

 "mp3player" - MP3 Music Player

 SWFObject - Hidding "object" behind JavaScript

 Flash Player Projector

 SWFTools - SWF File Manipulation Tools

SWFC Script to Generate Flash SWF Files

 What Is SWFC Script?

 circle.sc - First SWFC Script Example

 Frame.sc - Managing Animation Frames

Sound.sc - Adding Sound to Animation

 Text.sc - Add Text to Animation

 ActionScript Embedded in SWFC Script

 AS3Compile - ActionScript 3 Compiler

 Adobe Flex SDK 4

 SWF File Structure and Tags

 SWF File Processing Rules

 SWF Files for Video and Audio Streams

 Outdated Tutorials

 References

 Full Version in PDF/EPUB