1 Reply Latest reply on Nov 20, 2009 5:16 AM by _Natasha_

    Error 1120 in flex Builder acces of undefined properties

    Sorcery

      Hi

       

      I try to crete a simple xml reader, but flex builder found a error 1120: acces of undefined properties

       

      Can anyone help me?

       

      This is the code

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768">
           <mx:Script>
                <![CDATA[
                     import mx.collections.XMLListCollection;
                     import flash.xml.*;
                       import flash.net.*;
                       import flash.events.Event;
        
        
                     [Bindable]
                     private var company:XML;     
      
                     private var xmlString:URLRequest ;
                     private var xmlLoader:URLLoader ;
                     
                "err.1120"     xmlString = new URLRequest("data/data.xml");
                "err.1120"     xmlLoader= new URLLoader(xmlString);
                     
                "err.1120"     xmlLoader.addEventListener("complete", initXml);
                "err.1120 initXml"     
      
                     private function initXml(event:Event):void{     
                           company = XML(xmlLoader.data);
                     }
                     [Bindable]
                     private var companyData:XMLListCollection = new XMLListCollection(company.department);
                     
                     private function treeLabel(item:Object):String
                     {
                          
                          var node:XML = XML(item);
                          if( node.localName() == "department" )
                               
                               return node.@title;
                          else
                               return node.@name;
                     }
           
                ]]>
           </mx:Script>
           <mx:ApplicationControlBar x="0" y="0" width="1045">
           </mx:ApplicationControlBar>
           <mx:TabBar x="10" y="41" dataProvider="viewstack1">
           </mx:TabBar>
           <mx:ViewStack x="10" y="62" id="viewstack1" width="259" height="738">
                <mx:VBox label="Database" width="100%" height="100%">
                </mx:VBox>
                <mx:VBox label="Categoria" width="100%" height="100%">
                     <mx:Tree id="tree" width="256" height="570" 
                                dataProvider="{companyData}"
                                labelFunction="treeLabel"
                                
                                ></mx:Tree>
                </mx:VBox>
                <mx:HBox label="Search" width="100%" height="100%">
                </mx:HBox>
           </mx:ViewStack>
           <mx:DataGrid x="307" y="62" width="272.04547" height="569.3939">
                <mx:columns>
                     <mx:DataGridColumn resizable="false" sortable="false"/>
                     <mx:DataGridColumn headerText="Column 2" dataField="User"/>
                </mx:columns>
           </mx:DataGrid>
           
      </mx:Application>
      
        • 1. Re: Error 1120 in flex Builder acces of undefined properties
          _Natasha_ Level 4

          private var xmlString:URLRequest = new URLRequest("data/data.xml"); 
                         private var xmlLoader:URLLoader = new URLLoader(xmlString);
                                  // this string you can write only in a function           xmlLoader.addEventListener("complete", initXml);

          for example add creationComplete="initApp()" to Application

          and add

          private function initApp():void

          {

          xmlLoader.addEventListener("complete", initXml);

          }