-
tyro want to understand complex code?
Tyro to Actionscript ... please help my understanding of code???
Tyro to Actionscript ... please help my understanding of code???
I have two layers one is called actions
Other layer is called MP3-player – this layer has
• dynamic text field – I have called it “display_txt”
• btn_rev
• btn_play
• btn_stop
• btn_fw
Bellow is the code for the actions layer
Can someone annotate the code with what is happening so I can understand it.
I have a simple XML file called playlist.XML Here is the code for it:
<?xml version="1.0" encoding="UTF-8"?>
<songs>
<song name ="In Too Deep" file="mp3/track01.mp3" />
<song name ="Staceys Mom" file="mp3/track02.mp3" />
</songs>
One of my question is how long is the array?
Is it a double array? i.e. confused with “firstChild.chilNodes”
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
trace(songname[i]+" "+songfile[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_root.sound_mc.sound_obj = new Sound();
_global.song_nr = random(songfile.length);
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
MovieClip.prototype.songStarter = function(file, name) {
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
this._parent.display_txt.text = name;
} else {
this._parent.display_txt.text = "loading...";
}
};
this.sound_obj.onSoundComplete = function() {
(song_nr == songfiles.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfiles[song_nr], songname[song_nr]);
};
};
btn_play.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
btn_stop.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
};
btn_fw.onRelease = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
btn_rev.onRelease = function() {
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
playlist.load("playlist.xml");
Thank you in advance for your help
-
you get two arrays songfile and songname. each of them is a simple array like this:
songfile = [a,b,c,d,e];
XML.firstChild sets the pointer before the first node (here: "songs"),
XML.firstChild.firstChild sets the pointer to the first child of "songs" (here: the first "song" node)
and so on...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|