2 Replies Latest reply on Dec 27, 2006 9:23 AM by FlightGuy

    issue obtaining data from text file

    xyco45 Level 1
      <mx:Script>
      <![CDATA[
      import flash.events.*;
      import flash.net.*;
      public function testing():void
      {
      var loader:URLLoader = new URLLoader();
      loader.addEventListener(IOErrorEvent.IO_ERROR, handle);
      loader.addEventListener(Event.COMPLETE, handleEvent);
      loader.dataFormat = URLLoaderDataFormat.VARIABLES;
      loader.load(new URLRequest("params.txt"));

      }
      private function handleEvent(event:Event):void
      {
      var loader:URLLoader = URLLoader(event.target);
      t.text = data.monthNames;
      }
      private function handle(event:IOErrorEvent):void
      {
      t.text = "Unable load " + event.text;
      }
      ]]>
      </mx:Script>
      <mx:Label x="123" y="158" width="204" id="t"/>
      <mx:Button x="157" y="268" label="Button" click = "testing()"/>


      its very simple I hit a button and its suppose to open up the "params.txt" file.. bit its not.. the text file is located in the bin folder of my project. but everytime run it I get the #2032 error which is the "stream" error.... so clearly its either not finding the file or just not reading it properly..... not sure whats going on the contents of the file is "monthNames=september"

      any idea in to why its not working?
        • 1. Re: issue obtaining data from text file
          ntsiii Level 3
          URLLoader is a run-time operation, that gets executed by the client.

          I suspect that the relative url you are providing "params.txt" is not accessible in that form from the client.

          Try using a fully qualified url instead of a relative one.

          How are you executing the app/swf? From a server url or from a file url?

          Tracy
          • 2. Re: issue obtaining data from text file
            FlightGuy Level 1
            I think Tracy is right that you have a url problem - you might try fully qualifying your url. Also, however, I see you're setting, in your handleEvent function, t.text = data.monthNames. Not sure where "data" is coming from, but you probably mean loader.data.monthNames?