FLASH FDT - What's wrong with this code

66 views Asked by At

Sorry my poor english

I'm a newbie in ActionScript 3. In FLASH FDT I'm trying to load a xml file using this code:

/* some code */

var questionsURL:URLRequest = new URLRequest('questions.xml');
var loadXML:URLLoader = new URLLoader(questionsURL);
loadXML.addEventListener(Event.COMPLETE, questionsLoaded);

/* more code */

function questionsLoaded(e:Event):void {
    var myText:TextField = new TextField();
    myText.text = "File loaded!";
    addChild(myText);
}

The problem is that the event COMPLETE is never trigged.I never see the TextField with the text "File loaded!".

The project build successfully with no erros in FDT's Console... The xml file is in the same folder that generated swf file I'm using FDT Free.

Thanks for any help.

2

There are 2 answers

0
infor matica On

Thank you for your help. I find the solution: the problem was related with the security settings of Flash Player. I only have to add the FDT workspace as a trusted location for developer tests.

Sorry for my poor english.

0
am0wa On

I believe, it's because your xml file is never loaded, because of wrong path. Add the error listeners & handlers for them to see the error reason.

loadXML.addEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler );
loadXML.addEventListener(SecurityErrorEvent.SECURITY_ERROR, urlLoaderSecErrorHandler); 
...
/* handlers code */

and add some trace output into your questionsLoaded handler for debug purposes