2
votes

trying to see why I get this error every time I run this small piece of code in Flash!

the error: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

the code:

import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;

var xmlLoader:URLLoader;
var xml:XML;

var uRequest = new URLRequest("http://xxxxxxx/app.php");
xmlLoader = new URLLoader(uRequest);
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoad);
var imgLoader:Loader;

function onXMLLoad(e:Event) {
    xml = new XML(e.target.data);
    imgLoader = new Loader();
    imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImgLoaded);
    imgLoader.load(new URLRequest(xml.Data.Image.text()[0]));
}

function onImgLoaded(e:Event) {
    addChild(imgLoader);
}

The XXXXXXX is the url to my site by the way.

I just can find the reason why this error is getting spat out as I checked the URL a few times and it is correct URL.

2
You have TWO URLRequests, which one throws the error? - Vesper
Okay, I've fixed it. no worries. the path to the images had security issues and now it works. Thanks - David Smith
If so, add your own answer describing the fix and accept it, to not to confuse future readers. - Vesper
@Vesper, I added my own answer but I cannot accept for 2 days according to stackoverflow terms. - David Smith

2 Answers

5
votes

You should always listen for errors as well.

Ex:

imgLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onImgLoadError);

Most of the cases the path/url you are using it is not correct.

0
votes

All i needed to do was to change the settings and how the URL's was showing in my XML file.

I had to change the /images/image1.jpg to the full path like so: http://mysite.com//images/image1.jpg and this works fine.