Hello everyone, I ask for help. In Flash Builder 4.5, I try to connect to an XML file, but something doesn't work.

Below is the code (more precisely, a piece of code before the error):

<fx:Script> <![CDATA[ import flash.display.Sprite; import flash.events.Event; import flash.net.URLLoader; import flash.xml; var myXML: XML = new XML(); var XML_URL: String = "C:\req.xml"; var myXMLURL: URLRequest = new URLRequest(XML_URL); var myLoader: URLLoader = new URLLoader(myXMLURL); myLoader.addEventListener(Event.COMPLETE, xmlLoaded); 

and here on the last line the environment gives an error:

This line contains several selections:

-1120: Handling of a non-existent myLoader property.

-1120: Handling of a non-existent xmlLoaded property.

I am a newcomer to AS 3 and just can’t understand what my mistake is. Help, who can, please.

    1 answer 1

    About Flash Builder 4.5 not sure, but in ADOBE FLASH ACTIONSCRIPT 3 it looks like this.

    Events must be connected completely in FLASH , it looks like this:

     import fL.events.*; 

    In your case it’s like this:

     import Flash.events.*; var xml:XML = new XML(); var xmlList:XMLList =new XMLList(); var xmlRequest:URLRequest = new URLRequest('messages.xml'); var loader:URLLoader = new URLLoader(); loader.addEventListener (Event.COMPLETE,xmlLoaded); loader.load(xmlRequest); 

    You do not have this function:

     function xmlLoaded(e:Event):void { xml=XML(e.target.data); xmlList = xml.children(); ) 

    Yes, and in ACTIONSCRIPT 3 path "C:\req.xml" may cause an error, since there is a backslash in the line, it must be escaped - "C: \ req.xml".

    • The xmlLoaded function is declared below in that code. I, however, read the XML object by item. a little change your code by itself (variable names), I get the same errors. And not even in one line, like mine, but in two: loader.addEventListener (Event.COMPLETE, xmlLoaded) and loader.load (xmlRequest); everywhere the same mistake - 1120 Appeal of a non-existent property - Vladimir Archi
    • Here is a complete code that works var xml: XML = new XML (); var xmlList: XMLList = new XMLList (); loadXml (); function loadXml (e: MouseEvent = null): void {var xmlRequest: URLRequest = new URLRequest ('C: \\ list.xml'); var loader: URLLoader = new URLLoader (); loader.addEventListener (Event.COMPLETE, xmlLoaded); loader.load (xmlRequest); } function xmlLoaded (e: Event): void {xml = XML (e.target.data); xmlList = xml.children (); it's just the output in the text field to check for text_aww.text = xmlList [0] .name; } - vano
    • about errors there is an assumption that this is due to the appeal to xml. here xml looks like this <list> <list> <name> read check </ name> </ list> </ list> if in this line you replace the number 0 with 1 xmlList [0] .name, then an error will occur as a child < list> there is only one. Forget about the xmlList = xml.children (); we moved to the child <list> tag - vano
    • Strangely, on the third line (loadXml ();) an error occurs 1180 Calling the supposedly undefined loadXml method. - Vladimir Archi
    • loadXml (); This is the function that we described below. I wonder why such a compiled error in actionscript3 should find all the functions on the page and their call can be executed before the function is declared. Well, rass error means move the function call after they are declared. Ie votak: - vano