0 Replies Latest reply on Feb 15, 2010 12:16 PM by RosieGp

    FileReference and OPEN

    RosieGp Level 1

      I'm using FileReference to open files on server... here is my code.... whrn I run it it browse but when I hit open nothing happens and the brower box just close... Any idea what I'm missing..

      <mx:Script>

       

       

      <![CDATA[

       

      import mx.collections.ArrayCollection;

       

      import mx.rpc.events.ResultEvent;

       

      import mx.managers.PopUpManager;

       

      import mx.rpc.events.FaultEvent;

       

      import mx.controls.Alert;

       

      import flash.net.FileReference;

       

      [

      Bindable]

       

      private var fileRef:FileReference = new FileReference();

       

      private

       

       

       

       

       

      function get_data():void {

      View1.addEventListener(MouseEvent.CLICK, onButtonClick);

      }

       

      private function onButtonClick(e:MouseEvent):void

      {

       

      try

      {

      fileRef.browse([

      new FileFilter("Images", "*.jpg;*.gif;*.png")]);

      }

       

       

      catch (error:Error)

      {

       

      trace("Unable to browse for files.");

      }

      fileRef.addEventListener(Event.SELECT, onFileSelected);

      }

       

       

      private function onFileSelected(e:Event):void

      {

      fileRef.addEventListener(Event.OPEN, onFileLoaded);

       

       

       

       

      //e.target.parent.fileRef.load();

       

       

      }

       

       

       

      private function onFileLoaded(e:Event):void

      {

       

       

      var loader:Loader = new Loader();

      loader.loadBytes(e.target.data);

      addChild(loader);

      }

       

      ]]>

       

      </mx:Script>

       

      <mx:Button

       

      label="View"

      id="

      View1"

      click="get_data()"

      />