1 Reply Latest reply on Jun 21, 2008 12:07 PM by sandwicense

    Odd Problem With Code

    sandwicense Level 1
      I built and app that was set to run as an AIR application, now I want to take a section of the code I have in that AIR app and apply it to a regular Application that runs in the browser. I copied and pasted the code I wanted into the Web application and made sure everything was ok. It fits in perfectly with no errors and am able to successfully run it to preview and test it. The problem is that part of the code does not seem to execute. That part is the entire onComplete function. I am sure everything is fine because Flex Builder returns with no errors at all.

      This is how the app is suppose to work:

      1)XML list populates the Tree Control
      2)When a user clicks a tree node, a separate URL is loaded from an attribute inside the XML file that populates the tree. That attribute is called xmlLink.
      3) In multiple steps the URL from the XML attribute is stored into the bindable variable.
      4) (Located that very bottom of code) I have a Horizontal List that is suppose to populate with the second XML URL that is stored as the bindable variable. That variable is called TileListASDP.

      My entire MXML source code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:XML id="treeDP" source="URL_HERE" />
      <mx:Script>
      <![CDATA[
      /*
      //ALL "import" statements
      //import mx.controls.Alert;
      //import mx.controls.TextInput;
      //import mx.controls.Button;
      //import mx.events.ListEvent;
      */
      import mx.controls.*;
      import mx.events.*;
      import flash.events.*;
      import mx.containers.*;
      import mx.collections.*;
      import flash.events.*;
      import flash.net.*;
      import mx.core.*;
      import mx.managers.*;
      import mx.rpc.events.ResultEvent;

      private function treeLabelFunc(item:Object):String {
      var suffix:String = "";
      if (gTree.dataDescriptor.isBranch(item)) {
      suffix = " (" + item.children().length() + ")";
      }
      return item.@label + suffix;
      }

      //Select a Collection Node in the nMuseum Tree Control
      private var externalXML:XML;
      private function collectionSelect(event:Event):void {
      loadMyXML(event.currentTarget.selectedItem.@xmlLink);
      }


      private function loadMyXML(xmlname:String) : void {
      var loader:URLLoader = new URLLoader();
      var request:URLRequest = new URLRequest(xmlname);
      loader.load(request);
      loader.addEventListener(Event.COMPLETE, onComplete);
      }
      [Bindable]
      public var tileListASDP:XML;


      public function onComplete(event:Event):void {

      var loader:URLLoader = URLLoader(event.target);
      externalXML = XML(loader.data);
      tileListASDP = XML(externalXML);

      }
      ]]>
      </mx:Script>
      <mx:Tree x="0" y="0" backgroundAlpha="0" width="219" height="496" id="gTree" labelField="@label" dataProvider="{treeDP}" labelFunction="treeLabelFunc" borderThickness="0" horizontalScrollPolicy="on" selectedIndex="1" itemClick="collectionSelect(event);" creationComplete="openNode();"></mx:Tree>
      <mx:HorizontalList id="collectionBrowser" width="527" height="64" backgroundAlpha="0" borderThickness="0" borderStyle="none" dataProvider="{tileListASDP.imageDataSet}" allowMultipleSelection="false" enabled="true" horizontalScrollPolicy="on" selectedIndex="2" itemRenderer="IMGItemRenderer" itemClick="imgSelect(event);" columnCount="1" y="432" x="261"/>
      </mx:Application>