6 Replies Latest reply on Apr 20, 2010 12:26 PM by kfcdoubledown

    Issue with FileReference.load() on Mac/Firefox 3.6/FlashPlayer 10.0.45.2

    kfcdoubledown

      Hey there,

       

      After several days of banging my head against my desk trying to figure out what my application is doing wrong, I think I stumbled across a problem that either I'm not handling correctly in my code or that is a bug in the Flash Player plugin for Firefox on the Mac (and on Linux).

       

      Here are my specs:

      MacBook Pro with Snow Leopard 10.6.3

      Firefox 3.6.3 w/ Flash Plugin 10.0.45.2

      Safari 4.0.5 w/ Flash Plugin 10.0.45.2

      FlashBuilder 4.0 (272416)

      Flex 3.5 SDK

       

      I can't post the code I've been working on as it's for a work project; however, I found something on Adobe's site that manifests this problem:

       

      http://www.adobe.com/devnet/flash/quickstart/filereference_class_as3/

       

      If you open up this page in Firefox 3.6 on the Mac, you may notice that the crop box doesn't work properly (or at least I noticed this behavior).  What I would see is that the crop box would immediately fill to the lower right hand corner.

       

      Open up the same link in Safari and it works properly.

       

      The following is what I've noticed in my debugging efforts on my own application:

      • After completing a FileReference.load call, the Flash application appears to lose focus (perhaps to the operating system?)
      • Moving the cursor (both in my case and I think in the example on the site) results in getting undefined (and astronomical) values back when you poll for the mouse cursor's position.
      • Clicking outside of Firefox and clicking back in seems to resolve this.  It seems like leaving the window and returning solves the problem.

       

      To provide another example of this behavior, I've altered some code that does a similar function to the example on Adobe's site to produce some statistics about where the mouse cursor is:

       

      The code example:

      http://blog.flexexamples.com/2008/08/25/previewing-an-image-before-uploading-it-using-the- filereference-class-in-flash-player-10/#more-766

       

      My code (my changes are bolded):

      <?xml version="1.0" encoding="utf-8"?>
      <!-- http://blog.flexexamples.com/2008/08/25/previewing-an-image-before-uploading-it-using-the- filereference-class-in-flash-player-10/ -->
      <s:Application name="FileReference_load_test"
                     xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/halo"
                     xmlns:net="flash.net.*" xmlns:mx1="library://ns.adobe.com/flex/mx"
                     creationComplete="init()">
       
        <fx:Script>
          <![CDATA[
            import mx.controls.Alert;
            import mx.utils.ObjectUtil;
           
            [Bindable]
            private var appX:Number;
           
            [Bindable]
            private var appY:Number;
           
            private function init():void {
              addEventListener(MouseEvent.MOUSE_MOVE, handleMove);
            }
           
            private function handleMove(event:MouseEvent):void {
              appX = event.localX;
              appY = event.localY;
            }

           
            private function btn_click(evt:MouseEvent):void {
              var arr:Array = [];
              arr.push(new FileFilter("Images", ".gif;*.jpeg;*.jpg;*.png"));
              fileReference.browse(arr);
            }
           
            private function fileReference_select(evt:Event):void {
              fileReference.load();
            }
           
            private function fileReference_complete(evt:Event):void {
              img.source = fileReference.data;
              Alert.show(ObjectUtil.toString(fileReference));
            }
          ]]>
        </fx:Script>
       
        <fx:Declarations>
          <net:FileReference id="fileReference"
                             select="fileReference_select(event);"
                             complete="fileReference_complete(event);" />
        </fx:Declarations>
       
        <s:Panel id="panel"
                  horizontalCenter="0"
                  verticalCenter="0"
                  width="500">
          <s:layout>
            <s:VerticalLayout />
          </s:layout>
          <mx1:Image id="img"
                    verticalCenter="0"
                    horizontalCenter="0"
                    maxWidth="200"
                    maxHeight="200" />
          <mx1:ControlBar>
            <s:Button id="btn"
                       label="Browse and preview..."
                       click="btn_click(event);" />
            <s:Button label="Upload..."
                       enabled="false" />
            <s:Label text="MouseX:" />
            <mx1:Text text="{appX}" />
            <s:Label text="MouseY:" />
            <mx1:Text text="{appY}" />

          </mx1:ControlBar>
        </s:Panel>
       
      </s:Application>

       

      If you compile and run this application in Firefox, you should see that the X and Y values for the mouse stop updating after the file is loaded.  On Safari they continue to update.

       

      I couldn't find any reference to this problem searching on Google (perhaps not the right keywords?).

       

      Anyone have any input on this issue?  Any help is appreciated