December 2002
Beginner
478 pages
17h 55m
English
The SWF::Sound object allows you to read in an MP3 file that can
be played in the background of a movie. Add the sound to a particular
frame of the movie with the SWF::Movie::setSoundStream( ) method, as in
the following example:
my movie = new SWF::Movie;
my $sound = new SWF::Sound("goldenhair.mp3"); # A 30-second MP3
$movie->setRate(24);
# Make sure we have enough frames to accommodate the sound clip
# 30 seconds * 24 fps = 720 frames
$movie->setFrames(720);
$movie->setSoundStream($sound);If the movie is shorter than the length of the sound clip, the sound is truncated, so we add enough frames to the movie to accommodate the entire 30 seconds.
Read now
Unlock full access