2 Replies Latest reply on May 7, 2008 9:19 AM by DCMansell

    urlStream error

    DCMansell Level 1
      I'm running the exact same code in the exact same application under both Windows XP and Mac OS X, but getting a different result. The grab() function below is supposed to reach out to a file called grabber.txt on a set timer and interpret the results. When I do this under Windows, it works correctly and traces the "diff" message if grabber.txt has changed. Under OS X, it traces the "no diff" message after regrabbing the file, even if grabber.txt has changed.

      My code (trayce is my custom tracing function):

      public function grab():void {
      trayce("grabbing now " + Math.random());
      var urlReq:URLRequest = new URLRequest(dataSite + "grabber.txt");
      urlStream = new URLStream();
      fileData = new ByteArray();
      urlStream.addEventListener(Event.COMPLETE, grabberGrabbed);
      urlStream.addEventListener(IOErrorEvent.IO_ERROR, ioErrorListener);
      urlStream.load(urlReq);
      }

      //called if grabber.txt fails to load
      private function ioErrorListener(event:IOErrorEvent):void {
      trayce("Could not access grabber.txt")
      }

      //called when grabber.txt is done reading
      private function grabberGrabbed(event:Event):void {
      trayce("grabber.txt has been grabbed");
      urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
      var oldGrabbed:String = grabbed;
      grabbed = fileData.readUTFBytes(fileData.length);
      if(grabbed == oldGrabbed){
      trayce("no diff");
      } else {
      trayce("diff");
      }
      interpret();
      }