2 Replies Latest reply on Jun 14, 2007 7:24 PM by ntsiii

    Tree List Error

    shaungish Level 1
      I get the following error any time I click on a folder in my tree list:

      Error: Unable to load ''.
      at mx.controls::SWFLoader/::loadContent()
      at mx.controls::SWFLoader/load()
      at mx.controls::SWFLoader/mx.controls:SWFLoader::commitProperties()
      at mx.core::UIComponent/validateProperties()
      at mx.managers::LayoutManager/::validateProperties()
      at mx.managers::LayoutManager/::doPhasedInstantiation()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/::callLaterDispatcher2()
      at mx.core::UIComponent/::callLaterDispatcher()

      <b>Here's my code:</b>

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="dirListSvc.send();">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      import flash.net.FileReference;

      private var fileRef:FileReference;
      [Bindable]
      private var dirList:XML;
      [Bindable]
      public var selectedNode:XML;

      //file browse function
      private function fileBrowse():void {
      this.fileRef = new FileReference();
      fileRef.addEventListener(Event.SELECT, selectHandler);
      fileRef.browse();
      }

      private function selectHandler(event:Event):void {
      var request:URLRequest = new URLRequest(" http://localhost:8300/");
      fileRef.upload(request);
      }

      // Event handler for the Tree control change event.
      public function treeChanged(event:Event):void {
      selectedNode=Tree(event.target).selectedItem as XML;
      }

      private function directoryResultHandler(event:ResultEvent):void {
      dirList = event.result as XML;
      }

      // Fault handler - displays the error
      private function directoryFaultHandler(event:FaultEvent):void {
      Alert.show(event.fault.message, "Could not load dirList");
      }

      ]]>

      </mx:Script>

      <mx:HTTPService
      id="dirListSvc"
      url=" http://localhost/iqAssets/scripts/directory.php"
      resultFormat="e4x"
      result="directoryResultHandler(event);"
      fault="directoryFaultHandler(event);"
      />

      <mx:HDividedBox>
      <mx:VBox>
      <mx:Tree x="10" y="10" labelField="@label" dataProvider="{dirList}" width="250" change="treeChanged(event)"/>
      <mx:Button label="Upload A File" click="fileBrowse()"/>
      </mx:VBox>
      <mx:Panel height="300" width="400" title="{selectedNode.@label}">
      <mx:Text text="{selectedNode.@path}" />
      <mx:Image source="{selectedNode.@path}" />
      </mx:Panel>
      </mx:HDividedBox>

      </mx:Application>

      And here's my php:

      <?php

      function getDirectory( $path = '.', $level = 0 ){

      $ignore = array( 'cgi-bin', '.', '..' );
      // Directories to ignore when listing output. Many hosts
      // will deny PHP access to the cgi-bin.

      $dh = @opendir( $path );
      // Open the directory to the handle $dh
      while( false !== ( $file = readdir( $dh ) ) ){
      // Loop through the directory

      if( !in_array( $file, $ignore ) ){
      // Check that this file is not to be ignored

      $spaces = str_repeat( ' ', ( $level * 4 ) );
      // Just to add spacing to the list, to better
      // show the directory tree.

      if( is_dir( "$path/$file" ) ){
      // Its a directory, so we need to keep reading down...
      echo '<node label="'.$file.'">';
      getDirectory( "$path/$file", ($level+1) );
      // Re-call this same function but on a new directory.
      // this is what makes function recursive.
      echo '</node>';
      } else {

      $filename = strtolower($file) ;
      $exts = split("[/\\.]", $filename) ;
      $n = count($exts)-1;
      $exts = $exts[$n];
      $imageExt = array ('gif', 'jpg', 'swf', 'png');
      if ( !in_array($exts, $imageExt))
      {
      echo '<node label="'.$file.'" path=""/>';
      }
      else
      {
      $imgPath = substr($path, 1);
      echo '<node label="'.$file.'" path="'." http://localhost/iqAssets/scripts$imgPath/$file".'"/>';
      }
      }
      }
      }
      closedir( $dh );
      // Close the directory handle

      }
      echo '<node label="assets">';
      getDirectory( "." );
      echo '</node>';
      ?>
        • 1. Re: Tree List Error
          mattlohkamp
          For what it's worth, I have the exact same error message:

          quote:

          Error: Unable to load ''.
          at mx.controls::SWFLoader/::loadContent()
          at mx.controls::SWFLoader/load()
          at mx.controls::SWFLoader/mx.controls:SWFLoader::commitProperties()
          at mx.core::UIComponent/validateProperties()
          at mx.managers::LayoutManager/::validateProperties()
          at mx.managers::LayoutManager/::doPhasedInstantiation()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.core::UIComponent/::callLaterDispatcher2()
          at mx.core::UIComponent/::callLaterDispatcher()



          Here's my code:

          quote:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle" creationComplete="photoService.send();" >
          <mx:HTTPService
          id="photoService"
          url="data.xml"
          resultFormat="e4x"
          result="photoResultHandler(event);"
          fault="photoFaultHandler(event);"
          />


          <!-- Controller -->
          <mx:Script>
          <![CDATA[
          import flash.net.navigateToURL;
          import mx.controls.Alert;
          import mx.rpc.events.FaultEvent;
          import mx.rpc.events.ResultEvent;

          [Bindable]

          private var photoFeed:XML;


          private function photoResultHandler(event:ResultEvent):void{ // Result handler - gets called after xml is loaded.
          //Alert.show("Loaded xml!");
          photoFeed = event.result as XML;
          }


          private function photoFaultHandler(event:FaultEvent):void{ // Fault handler - if the xml can't be loaded
          Alert.show(event.fault.message, "Could not load photo xml");
          }
          ]]>
          </mx:Script>
          <mx:Panel paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10" title="phlex quick pic gallery v0.8" fontWeight="bold" horizontalAlign="center" id="container">
          <mx:Tile width="100%" height="100%">
          <mx:Repeater id="photos" dataProvider="{photoFeed.pic}">
          <mx:VBox
          xmlns:mx=" http://www.adobe.com/2006/mxml"
          horizontalAlign="center"
          >
          <mx:Image
          id="currentpic"
          source="{photos.currentItem.attributes.url}"
          />
          <mx:Text text="{photos.currentItem.attributes.title} by {photos.currentItem.attributes.author}"/>
          </mx:VBox>
          </mx:Repeater>
          </mx:Tile>
          <mx:ControlBar id="nav" horizontalAlign="center" verticalAlign="middle">
          <mx:LinkButton label="previous" id="previous" />
          <mx:Label text="3/18" fontWeight="normal" id="page" />
          <mx:LinkButton label="next" id="next" />
          </mx:ControlBar>
          </mx:Panel>
          </mx:Application>

          • 2. Re: Tree List Error
            ntsiii Level 3
            So what line is raising the error?
            Tracy