when I run this i get a runtime error about not being able to access local files. If I comment out the local xml file reference and uncomment the reference to sephirot's xml file. it works fine.

How can this be used to load local XML? And i think using the compiler switch to allow local access is not a good solution. in a previous post i mentioned not being able to use http when allow loca lis on, well then if you have vendors with services you rely on, you can't test dev builds with that compiler switch.

Here is my code to load some xml.




Startup.as:::

package
{
   
    import flash.net.URLLoader
    import flash.net.URLRequest
    import flash.events.*
    import XPLogger;
   
    public class Startup
    {
        private var mainXML:XML;
        private var loader:URLLoader;
       
        public function Startup()
        {
            loader = new URLLoader();
            loader.addEventListener(Event.COMPLETE, onComplete);
            //loader.load(new URLRequest(" http://www.sephiroth.it/tutorials/flashPHP/E4X/files/test.xml"));
            loader.load(new URLRequest("xml/test.xml"));
        }
       
        private function onComplete( e:Event ):void
        {
            mainXML = new XML(loader.data);
            XPLogger.debug( loader.data );
            XPLogger.debug( "xml loaded, start parsing using E4X syntax" );
        }
    }
}


Now the other thing im wondering about is if FlexBuilder somehow manages this internally when you're compiling the swfs. I am using FlashDevelop for this. I know someone mentioned all you have to do is use URLLoader and URLRequest. but it sure doesn't work for me.

can someone test this code and see if it works for FlexBuilder?

or if somone can create an example that works, help me out.

Thanks all!




PS: here is the XPLogger class:::

XPLogger.as::: (use Xpanel logger)


package
{
   
    import flash.net.LocalConnection;
    import flash.utils.getTimer;

    public class XPLogger extends Object
    {
        private static var s_lc:LocalConnection = null;
        public static var enabled : Boolean = true;
        public static var level   : Number  = LEVEL_ALL;
        public static var LEVEL_DEBUG:int       = 0x01;
        public static var LEVEL_INFORMATION:int = 0x02;
        public static var LEVEL_WARNING:int     = 0x04;
        public static var LEVEL_ERROR:int       = 0x08;
        public static var LEVEL_NONE:int        = 0xFF;
        public static var LEVEL_ALL:int         = 0x00;
       
        public static function debug( o : Object ):void
        {
            _send( LEVEL_DEBUG, o );
        }

        public static function info( o : Object ):void
        {
            _send(LEVEL_INFORMATION, o );
        }

        public static function error( o : Object ):void
        {
            _send( LEVEL_ERROR, o );
        }

        public static function message( o : Object ):void
        {
            _send( LEVEL_INFORMATION, o );
        }

        public static function warn( o : Object ):void
        {
            _send( LEVEL_WARNING, o );
        }

        public static function warning( o : Object ):void
        {
            _send( LEVEL_WARNING, o );
        }

        public static function trace( o : Object ):void
        {
            _send( LEVEL_DEBUG, o );
        }

        private static function _send( _level_:Number, o:Object ):void
        {
            if( _level_ < level )
                return;

            if( s_lc == null )
                s_lc = new LocalConnection();

            s_lc.send( "_xpanel1", "dispatchMessage", flash.utils.getTimer(), ( typeof o =="xml" ? o.toXMLString() : " " + o ), _level_ );
        }
    }
}





__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to