About loading and using external MP3 files
601
You can 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.
Reading ID3 tags in MP3 files
ID3 tags are data fields that are added to an MP3 file. ID3 tags contain information about the
file, such as the name of a song, album, and artist.
To read ID3 tags from an MP3 file, use the
Sound.id3
property, whose properties correspond
to the names of ID3 tags included in the MP3 file that you load. To determine when ID3 tags
for a downloading MP3 file are available, use the
Sound.onID3
event handler. Flash Player 7
supports version 1.0, 1.1, 2.3, and 2.4 tags; version 2.2 tags are not supported.
The following example loads an MP3 file named song1.mp3 into the
song_sound
Sound
object. When the ID3 tags for the file are available, the
display_txt
text field shows the
artist name and song name.
To read ID3 tags from an MP3 file:
1.
Create a new FLA file called
id3.fla
.
2.
Select Frame 1 on the Timeline and type the following code in the Actions panel:
this.createTextField("display_txt", this.getNextHighestDepth(), 0, 0,
100, 100);
display_txt.autoSize = "left";
display_txt.multiline = true;
var song_sound:Sound = new Sound();
song_sound.onLoad = function() {
song_sound.start();
};
song_sound.onID3 = function():Void {
display_txt.text += "Artist:\t" + song_sound.id3. "\n";
display_txt.text += "Song:\t" + song_sound.id3.so "\n";
};
song_sound.loadSound("http://www.helpexamples.com/flash/sound/
song1.mp3");
3.
Select Control > Test Movie to test the sound.
The ID3 tags appear on the Stage, and the sound plays.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...