5 Replies Latest reply on Aug 1, 2009 12:04 AM by David_F57

    The Air Filereference is-a-bug / isn't-a-bug saga

    David_F57 Level 5

      When using filereference and filereferencelist in conjunction with each all is fine with flex but the same code fails in Air because the filereference complete event doesn't fire. This problem has been raised closed and reraised as a bug(i have run out of fingers and toes so I can't give a reliable count of how many time), will it ever be resolved or is it languishing in the to hard basket ?

       

      the code: flex 3.2 to gumbo build 27-jul-09 no problems /  AIR 1 to 1.5 doesn't work

           private var fl:FileReferenceList=new FileReferenceList();
           private var fi:FileReference = new FileReference();
           private var ImageCount: int;
           private var ImageLoop : int;
      
           [Bindable] private var ImageCollection: ArrayCollection = new ArrayCollection();
           
           private function loadImages(): void
           {
                fl.addEventListener(Event.SELECT, selectedImages);
                var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png");
                fl.browse([imagesFilter]);
           }
      
           private function selectedImages(e:Event): void
           {
                fl.removeEventListener(Event.SELECT, selectedImages);
                ImageCollection.removeAll();
                ImageCount = fl.fileList.length;
                ImageLoop  = 0;
                loopList(0);
           }
           
           private function loopList(value:int): void
           {
                if (value < ImageCount)
                {
                 fi = fl.fileList[value];     
                 fi.addEventListener(Event.COMPLETE,getImage); << never fires
                 ImageLoop = ImageLoop+1;
                 fi.load();
                }
           }
           
           private function getImage(e:Event): void
           {
                 fi.removeEventListener(Event.COMPLETE, getImage);
                if (fi.data.length > 0)
                {
                var ba: ByteArray = new ByteArray();
                ba = fi.data;
                ImageCollection.addItem(ba);
                }
                loopList(ImageLoop);
            }
       
      

       

      If anyone has a work around for air this would be greatly appreciated.

       

       

      David

        • 1. Re: The Air Filereference is-a-bug / isn't-a-bug saga
          davidr_

          Can you give us a link to the bug reports you mention? Would help us debug your problem further the more info we get.

           

          One possible suggestion:

          Are you listening for all the possible errors from the FileReference? Perhaps there's an IOError or SecurityError or something?

           

          One possible workaround:

          Use File and FileStream instead of FileReferenceList and FileReference. File/FileStream are AIR-only, so maybe they're more likely to work under AIR?

          • 2. Re: The Air Filereference is-a-bug / isn't-a-bug saga
            David_F57 Level 5

            davidr_ wrote:

             

            Use File and FileStream instead of FileReferenceList and FileReference. File/FileStream are AIR-only, so maybe they're more likely to work under AIR?

             

            David's rule no.6: avoid dependencies - maybe I need to amend this to unless using AIR

             

            The code I provided works  as an application it should also work if it is wrapped in a spark windowedApplication. There is no way to debug the code there is no error generated, the event.COMPLETE just fails. you can't step into it you can't do anything to see what is happening.

             

            If the flex code won't run in AIR it is, to say the least, very disappointing.

             

            https://bugs.adobe.com/jira/browse/FP-398 this was closed becuase it worked for <application> it should have been tested for <windowedapplication>.

             

            try a bugs.adobe.com  search  "filereference load complete"

            there are several  "closed" bugs relating to filereference events yet these events still don't fire when wrapped in a windowed application.

             

             

            David.

            • 3. Re: The Air Filereference is-a-bug / isn't-a-bug saga
              davidr_ Level 1

              Well, I wouldn't consider using AIR classes inside an AIR application to be an added dependency. Personally I've only used File in the past, since before Flash 10, that was the only way to load local files. Only recently did they add the new FIleReference.load() command, and in my quick test I have the same problem as you: it seems to fail inside AIR, but work inside the browser.

              • 4. Re: The Air Filereference is-a-bug / isn't-a-bug saga
                David_F57 Level 5

                I like the ability to take code and wrap it with the least changes (always code coding practice). Also the provided code is 4-5 times faster than using AIR filestream, this is massive difference when loading 100-200 images. I will raise another bug and be more specific than others that have attempted to have this issue addressed.

                 

                David.

                • 5. Re: The Air Filereference is-a-bug / isn't-a-bug saga
                  David_F57 Level 5

                  bug raised

                   

                  https://bugs.adobe.com/jira/browse/SDK-22516

                   

                  hey - Adobe guys add Google Chrome  and Windows 7 RC to your bug management options .. please   (see I said it nicely)

                   

                  David.