0 Replies Latest reply on Sep 29, 2011 3:08 PM by madhooper

    example of how to use file instead of filereference (air) i need to access the files nativepath

    madhooper Level 1

      I'm creating a file uploader. The user needs to have a list and gallery view. My problem is that I can't access the images path (to display a thumnail in gallery view) using the filereference clas. I know I get the path to the selected file using the file class but all of my attempts to use the file class have failed. Here's my working code block using the file reference class. Can anyone show me to use get the same result using the file class. Thanks in advance for any assistance.

       

      // Called to add file(s) for upload

                                    private function addFiles():void {

                                              _refAddFiles = new FileReferenceList();

                                              _refAddFiles.addEventListener(Event.SELECT, onSelectFile);

                                              _refAddFiles.browse();

                                    }

       

        // Called when a file is selected

                                    private function onSelectFile(event:Event):void {

                                              var arrFoundList:Array = new Array();

        // Get list of files from fileList, make list of files already on upload list

                                              Alert.show(_refAddFiles.fileList.data);

                                              for (var i:Number = 0; i < _arrUploadFiles.length; i++) {

                                                        for (var j:Number = 0; j < _refAddFiles.fileList.length; j++) {

                                                                  if (_arrUploadFiles[i].name == _refAddFiles.fileList[j].name) {

                                                                            arrFoundList.push(_refAddFiles.fileList[j].name);

                                                                            _refAddFiles.fileList.splice(j, 1);

                                                                            j--;

                                                                  }

                                                        }

                                              }

                                              if (_refAddFiles.fileList.length >= 1) {

                                                        for (var k:Number = 0; k < _refAddFiles.fileList.length; k++) {

                                                                  _arrUploadFiles.push({

                                                                            name:_refAddFiles.fileList[k].name,

                                                                            size:formatFileSize(_refAddFiles.fileList[k].size),

                                                                            file:_refAddFiles.fileList[k]});

                                                        }

                                                        listFiles.dataProvider = _arrUploadFiles;

                                                        tile.dataProvider = _arrUploadFiles;

                                                        listFiles.selectedIndex = _arrUploadFiles.length - 1;