About creating progress animations for media files 629
trace("Cleared interval");
}
my_sound.loadSound("http://www.helpexamples.com/flash/sound/song2.mp3",
true);
my_interval = setInterval(updateProgressBar, 100, my_sound);
function updateProgressBar(the_sound:Sound):Void {
var pos:Number = Math.round(the_sound.position / the_sound.duration *
100);
pb.bar_mc._xscale = pos;
pb.vBar_mc._x = pb.bar_mc._width;
pb.pos_txt.text = pos + "%";
}
3.
Select Control > Test Movie to load the MP3 file and watch the progress bar.
For more information on using sound, see the Sound class entry,
Sound, in the
ActionScript 2.0 Language Reference.
You can find a sample source file that uses scripted animation to create a progress bar
animation. Find tweenProgress.fla in the Samples folder on your hard disk.
■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Tween ProgressBar.
■ On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Tween ProgressBar.
You can also find a sample source file that loads MP3 files, jukebox.fla, in the Samples folder
on your hard disk. This sample demonstrates how to create a jukebox by using data types,
general coding principles, and several components.
■ In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\Components\Jukebox.
■ On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/Components/Jukebox.
NOTE
If you test this code a second time, the image will be cached and the progress bar will
complete right away. To test multiple times, use different images and load them from
an external source. A local source might cause problems with testing your
application because the content loads too quickly.