Friday, May 18, 2012

[Action Script] links from external XML work, but xml is not loading anymore after. May,2012

Hope somebody can help me...I have an external XML file loading in Flash. It worked perfect but since this week not anymore. The links in the XML file are the problem. I have no idea why.
In Flash I get the message:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
The XML is loading the first time I click on the button and the link works, but after that no text and links are loading at all!

I give the code that I use:
var txtFld:TextField = new TextField();
var txtFmt:TextFormat = new TextFormat();

var xml:XML;
var urlLoader:URLLoader = new URLLoader();
var urlRequest:URLRequest = new URLRequest("background.xml");
urlLoader.load(urlRequest);
urlLoader.addEventListener(Event.COMPLETE, onComplete, false,0,true);
function onComplete(evt:Event):void {
evt.target.removeEventListener(Event.COMPLETE, onComplete);
xml = new XML(evt.target.data);
}

txtFmt.font = avenirRoman.fontName;
txtFmt.size = 12;
txtFmt.leading = 4;
txtFmt.color = 0x616161;
txtFld.defaultTextFormat = txtFmt;
txtFld.embedFonts = true;
txtFld.antiAliasType = AntiAliasType.ADVANCED;
txtFld.thickness = -100;
txtFld.sharpness = 50;
txtFld.multiline = true;
txtFld.wordWrap = true;
txtFld.width = 500;
txtFld.autoSize = TextFieldAutoSize.LEFT;
txtFld.x = 270;
txtFld.y = 145;



btn10.addEventListener("click", afterClick2);
function afterClick2(e:Event):void {
txtFld.htmlText = xml.INFO[0].toString();
addChild(txtFld);

}

btn11.addEventListener("click", afterClick3);
function afterClick3(e:Event):void {
txtFld.htmlText = xml.INFO[1].toString();
addChild(txtFld);

}

btn12.addEventListener("click", afterClick4);
function afterClick4(e:Event):void {
txtFld.htmlText = xml.INFO[2].toString();
addChild(txtFld);

}

Then I tried to put in extra (IOErrorEvent) code:


***urlLoader.addEventListener(IOErrorEvent.IO_ERRO R, catchIOError);
function catchIOError(event:IOErrorEvent){
trace("Error caught: "+event.type);
}
urlLoader.load(new URLRequest("Invalid XML URL"));
trace("Continuing with script...");***

Then I get the message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main3_fla::MainTimeline/afterClick2()

And the XML file is not loading at all.If I take out all the links in the XML, text is loading perfect.


example of the XML:

<?xml version="1.0" encoding="utf-8"?>
<GALLERY>


<INFO TITLE><![CDATA[<u><a href=url>website</a>]]></INFO>

</GALLERY>
Can anybody tell me what's wrong?
Thanks
links from external XML work, but xml is not loading anymore after.

Related Post



0 comments: