Hi all Im having an issue with XML URLLoader in flash while swf is running in flex.
I can communicate back and 开发者_StackOverflowforth sending variables and arrays back and forth from the 2 no problem at all but have found an anomaly that I can’t find any answers on the web for.
Now my problem is as follows the code below works perfectly fine when I run it in flash but when I export the swf and run it in flex as a swf loader component the “processXML function wont fire” or it is firing but the URLLoader isn’t retrieving the information from the XML file. When I run the swf on its own it works no problem but flex seems to stop the connection. Everything else in the swf works as expected.
I also found that if I add a stage.addEventListener to the swf, flex disables everything in the swf.
The following code resides in the root time line of the flash component. And the test.XML file is in the root folder of the flash swf and flex src/ folder. Im not getting any errors... it just wont work lol
////XML Loader/////
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("test.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void
{
myXML = new XML(e.target.data);
}
function AfricaClick (event:MouseEvent):void
{
if(myXML.COUNTRY[0] == "yes")
{
gotoAndStop(2);
trace(myXML);
}
}
Really would appreciate some help on this.
myLoader.load(new URLRequest("test.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
1st of all - switch the functions places. You basicaly call the load procedure, before handle is attached... so my 1st suggestion is to switch their executional places as follow :
myLoader.addEventListener(Event.COMPLETE, processXML);
myLoader.load(new URLRequest("test.xml"));
精彩评论