2 Replies Latest reply on Sep 21, 2009 10:09 AM by cyber0897

    image uploader help

    cyber0897 Level 1

      hey guys, i need some help... i need to create an image uploader that basically will send a bitmap to a function as a parameter...

      i have the following code so far... but i am unable to get the bitmap...


      any help will be appretiated...!


      // ActionScript file
                  import flash.display.Bitmap;
                  import mx.controls.Alert;
                  import mx.controls.ProgressBarMode;
                  import services.images.ImageData;
                  public var fileRef:FileReference;
                  public var nLoader:Loader;
                  public var imgData:ImageData;
                  public function onBrowseButtonClicked(event:MouseEvent):void{
                      fileRef = new FileReference();
                      fileRef.addEventListener(Event.SELECT, onFileSelected);
                      //var swfFilter:FileFilter = new FileFilter("SWF Files(*.jpg)","*.jpg");
                      var allTypeFilter:FileFilter = new FileFilter("All Files (*.*)","*.*");
                  public function onFileSelected(event:Event):void{
                      fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
                      fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                      fileRef.addEventListener(IOErrorEvent.IO_ERROR, onFileLoadedError);
                  public function progressHandler(event:ProgressEvent):void{
                      var file:FileReference = FileReference(event.target);
                      var percentLoaded:Number = event.bytesLoaded/event.bytesTotal*100;
                      progressBar.mode = ProgressBarMode.MANUAL;
                      progressBar.minimum = 0;
                      progressBar.maximum = 100;
                      progressBar.setProgress(percentLoaded, 100);
                  public function onFileLoaded(event:Event):void{
                      var fileReference:FileReference = event.target as FileReference;
                      var data:ByteArray = fileRef['data'];
                      nLoader = new Loader();
                      nLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
                  public function onFileLoadedError(event:Event):void{
                  public function onLoaderComplete(event:Event):void{
                      var theImage:Bitmap;
                      theImage = nLoader as Bitmap;