# I need an xml explanation

**URL:** https://forum.kirupa.com/t/i-need-an-xml-explanation/271066
**Category:** flash
**Created:** [September 17, 2008, 11:58pm UTC](https://forum.kirupa.com/t/i-need-an-xml-explanation/271066 "2008-09-17T23:58:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mattvisk](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mattvisk](https://forum.kirupa.com/u/mattvisk)
#### Post date: [September 17, 2008, 11:58pm UTC](https://forum.kirupa.com/t/i-need-an-xml-explanation/271066/1 "2008-09-17T23:58:22Z")

</div>

can someone just comment the hell out of this script for me so i know whats going on.  
import mx.transitions.Tween;  
import mx.transitions.easing.\*;

var song\_folder:String = “songs/”;  
var song\_list:Array = new Array();  
var track\_list:Array = new Array();  
var artist\_list:Array = new Array();  
var album\_list:Array = new Array();  
var current:Number = 0;  
var position:Number;  
var new\_volume:Number = 100;  
var flash\_xml:XML = new XML();  
flash\_xml.ignoreWhite = true;  
flash\_xml.onLoad = function()  
{  
var nodes:Array = this.firstChild.childNodes;  
for(var i = 0; i \< nodes.length; i++)  
{  
song\_list.push(nodes\*.attributes.filename);  
track\_list.push(nodes\*.attributes.track);  
artist\_list.push(nodes\*.attributes.artist);  
album\_list.push(nodes\*.attributes.album);  
}  
play\_song(“start”);  
}  
flash\_xml.load( song\_folder + “songs.xml”);

btn\_play.play\_pause.onRelease = function()  
{  
if( this.\_parent.\_currentframe == 1 )  
this.\_parent.\_parent.play\_pause(“pause”);  
else  
this.\_parent.\_parent.play\_pause(“play”);

```
this._parent.play();

```

}  
btn\_prev.onRelease = function()  
{  
this.\_parent.play\_song(“prev”);  
}  
btn\_next.onRelease = function()  
{  
this.\_parent.play\_song(“next”);  
}  
function play\_song(track:String):Void  
{  
if(track == “prev”)  
current–;  
else if(track == “start”)  
current = 0;  
else  
current++;

```
if(current == song_list.length)
    current = 0;
else if(current &lt; 0)
    current = song_list.length - 1;

s = new Sound(); s.loadSound(song_folder + song_list[current], true);
s.setVolume(new_volume);
track_title.text = track_list[current];
artist_name.text = artist_list[current];
album_title.text = album_list[current];
track_info.text = "Song " + (current+1) + " of " + song_list.length;
btn_play.gotoAndStop(1);

```

}  
function play\_pause(pp:String):Void  
{  
if(pp == “pause”)  
{  
position = s.position;  
s.stop();  
}  
else if(pp == “play”)  
{  
s.start(position/1000);  
}  
}  
var my\_interval:Number;  
my\_interval = setInterval(update\_bar, 100);  
function update\_bar():Void  
{  
var total\_seconds:Number = s.duration/1000;  
var minutes:Number = Math.floor(total\_seconds/60);  
var seconds = Math.floor(total\_seconds)%60;  
if(seconds \< 10)  
seconds = “0” + seconds;

```
var total_current_seconds:Number = s.position/1000;
var current_minutes:Number = Math.floor(total_current_seconds/60);
var current_seconds = Math.floor(total_current_seconds)%60;
if(current_seconds &lt; 10) 
    current_seconds = "0" + current_seconds;

percent_loaded = Math.round(s.getBytesLoaded() / s.getBytesTotal() * 100);

    
player_bar._width = Math.round( s.position/s.duration*player_bar_bg._width );
btn_pointer._x = player_bar._width + player_bar._x;
    
position_info.text = current_minutes +":"+ current_seconds + " | " + minutes +":"+ seconds;
if( s.getBytesLoaded() == s.getBytesTotal() && s.position == s.duration )
    play_song();

```

}

btn\_pointer.onPress = function()  
{  
this.startDrag(true, player\_bar\_bg.\_x, this.\_y, player\_bar\_bg.\_width + player\_bar\_bg.\_x, this.\_y );  
s.stop(); clearInterval(my\_interval);  
}  
btn\_pointer.onRelease = btn\_pointer.onReleaseOutside = function()  
{  
this.stopDrag();  
new\_position = s.duration \* (this.\_x - player\_bar\_bg.\_x) / (player\_bar\_bg.\_width \* 1000);  
s.start(new\_position); btn\_play.gotoAndStop(1);  
my\_interval = setInterval(update\_bar, 100);  
}  
btn\_volume\_pointer.onPress = function()  
{  
this.startDrag(true, player\_volume\_bg.\_x, this.\_y, player\_volume\_bg.\_width + player\_volume\_bg.\_x, this.\_y );  
}  
btn\_volume\_pointer.onRelease = btn\_volume\_pointer.onReleaseOutside = function()  
{  
this.stopDrag(); new\_volume = this.\_x - player\_volume\_bg.\_x;  
new Tween(player\_volume, “\_width”, Strong.easeOut, player\_volume.\_width, new\_volume, 1.5, true);  
s.setVolume(new\_volume);  
}
