Created
August 21, 2008 20:38
-
-
Save mando/6637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This class is utilized as a document class in the mp3player.fla file. | |
* Once finished, the purpose of the class is to be a portion of a flash | |
* MP3 player. | |
* Author: <a href="mailto:[email protected]"> Kristine Orr </a> | |
* <dl> | |
* <dt>2008-05-12 v1.0.0</dt><dd>This is version one point zero.</dd> | |
* </dl> | |
*/ | |
package mp3Player | |
{ | |
import flash.display.*; | |
import flash.events.*; | |
import flash.net.*; | |
public class mp3Player extends Sprite | |
{ | |
//Class variable to define the XML object | |
public var playlist:XML; | |
/** | |
* Constructor. Calls loadXML method. | |
* @return mp3Player | |
*/ | |
public function mp3Player() | |
{ | |
loadXML(); | |
} | |
/** | |
* Method to load XML. | |
* @return void | |
*/ | |
public function loadXML():void | |
{ | |
var loader:URLLoader = new URLLoader(); | |
loader.dataFormat = URLLoaderDataFormat.TEXT; | |
loader.addEventListener( Event.COMPLETE, handleComplete); | |
loader.load( new URLRequest( "playlist.xml") ); | |
} | |
/** | |
* Method to convert the loaded XML text from a Loader on the COMPLETE event into an XML data object. | |
* @param event Event object passed from the Loader instance. | |
* @return void | |
*/ | |
private function handleComplete(event:Event):void | |
{ | |
try | |
{ | |
playlist = new XML(event.target.data); | |
trace("XML parsed correctly"); | |
} | |
catch (e:TypeError) | |
{ | |
trace("Could not parse text into XML"); | |
trace(e.message); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment