views:

236

answers:

2

hi,

i have faced this problem couple of days ago, while trying to import an external xml file into an AIR application.

 import flash.net.URLRequest;
 var ldr:Loader = new Loader();
 var url:String = "http://willperone.net/rss.php";
 var urlReq:URLRequest = new URLRequest(url);
 ldr.load(urlReq);
 ldr.addEventListener(Event.COMPLETE , function(e) {
    trace('Wow, completed ...');
 });
 ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(e) {
    trace('IO_ERROR');
 });

and always the IO_ERROR shows up. may i do it wrong or something needs a little of configuration, so please help

+2  A: 

The IOErrorEvent is telling you that it can't load the resource you are trying to load. Is there anything actually at http://willperone.net/rss.php. Perhaps an XML or PHP parse error? I also just noticed you are using Loader to try to load text content. The class you want to use to load XML (or text, json, binary, etc.) is URLLoader. Loader is a DisplayObject subclass mostly for loading swfs, images, and visual assets into the display list. This is the likely culprit.

Typeoneerror
thank you,actually i tried using the URLLoader with diffrent url and the same error still shows up and here is some details IO_ERROR[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2035: URL Not Found. URL: http://willperone.net/rss.php" errorID=2035]please note am testing the code by creating a new AIR project using flash cs4, i don't why it shows up ...
Ayman
If you can navigate to the URL in your browser, then I'd think it's maybe some kind of php header() issue. Check that your resource is valid XML to start.
Typeoneerror
A: 

Thank you guys, i found where the problem is : i didn't specify the type of the received content, it solved when i used

request.contentType = "text/xml";

so the code will look like this :

function getData(onComplete) {
    var request:URLRequest = new URLRequest("http://...");
    request.contentType = "text/xml";
    request.data = "";
    request.method = URLRequestMethod.POST;
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE ,function(e) { xmlParser(e); onComplete(e); } );
    try
    {
        mainData.splice(0,mainData.length);
        loader.load(request);
        return true;
    }
    catch (e){
        return false;
    }
}


function xmlParser(e) {
    var xml:XML = new XML(URLLoader(e.target).data);
    }
}
Ayman

related questions