I've written a class to deal with this. Just add an event listener to the
instance and upon load completion it dispatches a "complete" event. You can
then access the xml with instancename.xml;

:)

package efnx.net {

    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.EventDispatcher;

    /**
     *    PlaylistParser loads and parses the playlist, distributing the
loaded vars globally.
     *
     *    @langversion ActionScript 3.0
     *    @playerversion Flash 9.0
     *
     *    @author Schell Scivally
     *    @since  02.06.2008
     */
    public class PlaylistParser extends EventDispatcher {


/*---------------------------------------------------------------------------------------------------*/
        /*  CLASS CONSTANTS
                                              CLASS CONSTANTS */

/*-------------------------------------------------------------------------------------------------*/


/*---------------------------------------------------------------------------------------------------*/
        /*  PRIVATE VARIABLES
                                                 PRIVATE VARIABLES  */

/*-------------------------------------------------------------------------------------------------*/
        private var loader:URLLoader = new URLLoader();
        private var request:URLRequest = new URLRequest();
        private var loading:Boolean = false;

/*---------------------------------------------------------------------------------------------------*/
        /*  PUBLIC VARIABLES
                                                  PUBLIC VARIABLES  */

/*-------------------------------------------------------------------------------------------------*/
        public var xml:XML;

/*---------------------------------------------------------------------------------------------------*/
        /*  CONSTRUCTOR
                                                CONSTRUCTOR  */

/*-------------------------------------------------------------------------------------------------*/

        /**
         *    @Constructor
         */
        public function PlaylistParser()
        {
            super();
        }


/*---------------------------------------------------------------------------------------------------*/
        /*  GETTER/SETTERS
                                          GETTER/SETTERS  */

/*-------------------------------------------------------------------------------------------------*/


/*---------------------------------------------------------------------------------------------------*/
        /*  PUBLIC METHODS
                                              PUBLIC METHODS  */

/*-------------------------------------------------------------------------------------------------*/
        public function load(url:String):void
        {
            if(loading)
            {
                loader.close();
                loader.removeEventListener("complete",
loadPlaylistComplete);
                loader.removeEventListener("ioError", loadPlaylistError);
            }

            loader.addEventListener("complete", loadPlaylistComplete, false,
0, true);
            loader.addEventListener("ioError", loadPlaylistError, false, 0,
true);
            loading = true;
            request.url = url;
            loader.load(request);
        }
        /**
        *
        */

/*---------------------------------------------------------------------------------------------------*/
        /*  EVENT HANDLERS
                                       EVENT HANDLERS   */

/*-------------------------------------------------------------------------------------------------*/
        private function loadPlaylistComplete(event:Event):void
        {
            loader.removeEventListener("complete", loadPlaylistComplete);
            loader.removeEventListener("ioError", loadPlaylistError);
            loading = false;

            xml = XML(loader.data);

            dispatchEvent(new Event("complete"));
        }
        private function loadPlaylistError(event:IOErrorEvent):void
        {
            ////trace("PlaylistParser::loadPlaylistError() " + event.text);
        }

/*---------------------------------------------------------------------------------------------------*/
        /*  PRIVATE/PROTECTED METHODS
                                PRIVATE/PROTECTED METHODS  */

/*-------------------------------------------------------------------------------------------------*/

    }

}
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to