Hey there,

My friend has bought a MP3 player which i must say is pretty awesome. However they need to be able to load a variable xml file based on a php script they have.

They've asked me to take a look at it and tbh it is well above my skill set. below is snippet of the code nad if anyone would like the chance to take a look i'd seriously appreciate it.

Currently it loads the songs from a specifed folder.

function getSongData(songPath:String, imagePath:String, count:Number):void{

var track:Array = new Array();
track["path"] = songPath;
track["image"] = imagePath;

// CREATE A NEW URLLOADER TO LOAD THE PHP FILE
var getSongInfo:URLLoader = new URLLoader();
getSongInfo.dataFormat = URLLoaderDataFormat.VARIABLES;
getSongInfo.addEventListener(Event.COMPLETE, receivedSongData);

// CREATE A NEW URLREQUEST VARIABLE
var getSongInfoRequest:URLRequest = new URLRequest(phpPath + "getSongID3.php");
getSongInfoRequest.method = URLRequestMethod.POST;

// CREATE A NEW URLVARIABLES VARIABLE
var getSongInfoVariables:URLVariables = new URLVariables;
getSongInfoRequest.data = getSongInfoVariables;

// ADD A VARIABLE TO SEND
getSongInfoVariables.filePath="../" + songPath;

try {
getSongInfo.load(getSongInfoRequest);
} catch (err:SecurityError) {
trace("security error: " + err.message);
}

// When data has been sent
function receivedSongData(event:Event):void {
var getSongInfo2:URLLoader = URLLoader(event.target);
getSongInfo2.dataFormat = URLLoaderDataFormat.VARIABLES;
var getSongInfoVariables2:URLVariables = new URLVariables(getSongInfo2.data);
track["album"] = getSongInfoVariables2.album;
track["artist"] = getSongInfoVariables2.artist;
track["genre"] = getSongInfoVariables2.genre;
track["length"] = getSongInfoVariables2.length;
track["title"] = getSongInfoVariables2.title;
if (track["title"] == ""){
var tempSongArray:Array = songPath.split("/");
var errorArray:Array = tempSongArray[tempSongArray.length -1].split("'");
if (errorArray.length > 1){
track["title"] = "Error 101: " + tempSongArray[tempSongArray.length -1];
} else {
track["title"] = tempSongArray[tempSongArray.length -1];
}
}
populateSongs(track, count);
}

}

// LOAD THE SELECTED SONG
function loadSong():void{
// CREATE A NEW SOUND
snd = new Sound();
// ADD AN EVENT LISTENER FOR WHEN THE SONG HAS COMPLETELY LOADED
snd.addEventListener(Event.COMPLETE, loadComplete);
// ADD AN EVENT LISTENER FOR WHEN THE ID3 HAS LOADED
snd.addEventListener(Event.ID3, id3Handler);
// CREATE A URLREQUEST FOR THE NEW SONG
var sngReq:URLRequest = new URLRequest(song.path);
// LOAD THE SOUND WITH THE SONG PATH & SET STREAMING TO TRUE
snd.load(sngReq);
sndChannel = new SoundChannel();
// START THE SONG
sndChannel = snd.play(0);
// ADD AN EVENT LISTENER FOR THE END OF THE SONG
sndChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
// SET THE VOLUME OF THE SONG
sndTransform = sndChannel.soundTransform;
if (muteToggle){
sndTransform.volume = 0;
sndChannel.soundTransform = sndTransform;
} else {
sndTransform.volume = volSelect.currSelect/10;
sndChannel.soundTransform = sndTransform;
}
// ADD LISTENER TO THE LOADED BAR
loadedBar.addEventListener(MouseEvent.MOUSE_DOWN, seekBarDown);
// CALL FUNCTION TO ROTATE THROUGHT THE SONGS ATTRIBUTES
rotateSongText(false);
// LOAD THE IMAGE FOR THE SONG
loadSongImage();
// ADD AN ENTERFRAME LISTENER
home.addEventListener(Event.ENTER_FRAME, enterFrameListener);
// TURN THE VISUALIZER ON
visualizer.startup();
// SET THE PAUSEPOSITION
playPauseToggle = "play";
// TOGGLE THE playPauseBtn
playPauseBtn.up(playPauseToggle);
}





If you feel you cna help please private message me. As there is a lot more that comes with that.

Cheers

G