6 Replies Latest reply on Oct 3, 2010 11:58 AM by Astraport2012

    Warnings in FileReference - can not find the cause

    Astraport2012 Level 1

      I'm trying to make a loader of a few photos (use FileReference). I get the warnings, but I do not know the reason for their appearance.

       

       

      warning: unable to bind to property 'fr' on class 'Object' (class is not an IEventDispatcher)

      warning: unable to bind to property 'name' on class 'flash.net::FileReference'

      warning: unable to bind to property 'data' on class 'flash.net::FileReference'

      warning: unable to bind to property 'fr' on class 'Object' (class is not an IEventDispatcher)

      warning: unable to bind to property 'name' on class 'flash.net::FileReference'

      warning: unable to bind to property 'data' on class 'flash.net::FileReference'

       

      CODE:

       

      import mx.events.CollectionEvent;

      import flash.net.FileReferenceList;

      import mx.collections.ArrayCollection;

       

       

      [Bindable]

      private var photos:ArrayCollection = new ArrayCollection;

      private var frList:FileReferenceList = new FileReferenceList;

       

       

      private function init():void

      {

      photos.addEventListener(CollectionEvent.COLLECTION_CHANGE,function():void

      {

      startUploadButton.enabled = (photos.length>0);

      clearPhotosButton.enabled = (photos.length>0);

      });

      frList.addEventListener(Event.SELECT,addPhotos);

      }

       

       

      private function selectPhotos():void

      {

      var fileFilter:FileFilter = new FileFilter("Images jpeg","*.jpg;*.jpeg");

      frList.browse([fileFilter]);

      }

       

       

      private function addPhotos(e:Event):void

      {

      for (var i:uint = 0; i < frList.fileList.length; i++)

      {

      var elem:Object = new Object;

      elem.fr = FileReference(frList.fileList[i]);

      elem.fr.load();

      elem.fr.addEventListener(Event.COMPLETE,refreshThumb);

      photos.addItem(elem);

      }

      }

       

       

      private function refreshThumb(e:Event):void

      {

      photosList.invalidateList();

      }

       

       

      public function clearPhoto(data:Object):void

      {

      photos.removeItemAt(photos.getItemIndex(data));

      photosList.invalidateList();

      }

       

       

      private function startUpload():void

      {

      photosProgressContainer.visible = true;

       

      var request:URLRequest = new URLRequest();

      request.url = "http://localhost/tempLoader-debug/upload.php";

       

      var fr:FileReference = photos.getItemAt(0).fr;

      fr.cancel();

      fr.addEventListener(ProgressEvent.PROGRESS,uploadProgress);

      fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadComplete);

      fr.upload(request);

      }

       

       

      private function uploadProgress(e:ProgressEvent):void

      {

       

      photosProgress.setProgress(e.bytesLoaded,e.bytesTotal);

      }

       

       

      private function uploadComplete(e:DataEvent):void

      {

      photos.removeItemAt(0);

       

      photosList.invalidateList();

      if (photos.length > 0)

      startUpload();

      else

      photosProgressContainer.visible = false;

      }

        • 1. Re: Warnings in FileReference - can not find the cause
          Claudiu Ursica Level 4

          var elem:Object = new Object;

          elem.fr ....

           

          Are you by any chance using the fr property as source for a databinding

          somewhere? or other props?

          If so change your elem to be of a custom bindable class. Object is not bindable

          by itself since EventDispatcher si not the parent of the Object class.

           

           

          public class CustClass

          {

              public var name:String etc....

          }       

           

          C

          • 2. Re: Warnings in FileReference - can not find the cause
            Astraport2012 Level 1

             

            Thanks, i made it but all warnings are still displayed.

            • 3. Re: Warnings in FileReference - can not find the cause
              Astraport2012 Level 1

              I found the solution to the first part of the warning. Only need to modify the object as ObjectProxy

               

              [Bindable]

              public var elem:ObjectProxy = new ObjectProxy;

               

              But with the second part is still a problem (warning: unable to bind to property 'name' on class 'flash.net::FileReference'

              warning: unable to bind to property 'data' on class 'flash.net::FileReference').

              I do not fully describe the problem in the first message. The main application calls the component and passes it parameters. They cause errors.

               

              It is this component photoThumb.mxml:

               

              <?xml version="1.0" encoding="utf-8"?>

              <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"

                 width="120" height="110"

                 backgroundColor="#FFFFFF" backgroundAlpha="0"

                 rollOver="{controls.visible=true;}" rollOut="{controls.visible=false;}">

              <mx:Image source="@Embed('t1.png')" width="100%" height="100%" alpha="0" horizontalAlign="center" verticalAlign="middle"/>

              <mx:VBox width="100%" height="90" y="5" horizontalAlign="center" >

              <mx:Image source="{data.fr.data}" maxWidth="100" maxHeight="75" horizontalAlign="center" verticalAlign="middle" />

              </mx:VBox>

              <mx:Label text="{data.fr.name}" width="118" truncateToFit="false" bottom="0" textAlign="center" />

              <mx:VBox id="controls" visible="false" y="65" right="10" horizontalAlign="right" >

              <mx:Button label="X" click="parentDocument.clearPhoto(data)" fontSize="6" width="30" height="15" />

              </mx:VBox>

              </mx:Canvas>

              • 4. Re: Warnings in FileReference - can not find the cause
                Claudiu Ursica Level 4

                In my opinion this is the line that is causing you the warning:

                 

                <mx:Image source="{data.fr.data}" maxWidth="100" maxHeight="75"

                horizontalAlign="center" verticalAlign="middle" />

                 

                That means that data should be a custom binable object and fr should be another

                custom bindable object.

                 

                like

                 

                public class BindableData

                {

                    public var fr:BindableData2;

                }

                 

                public class BindableData2

                {

                    public var data:String;

                }

                 

                I am not sure though what you are trying to do though, but I assume you try top

                load an image from your disk. This link will help you:

                view source enabled...

                http://www.everythingflex.com/flex3/flexcampItaly/

                 

                the blog post ...

                http://blog.everythingflex.com/2009/09/08/flexcamp-presentation-filereference-load-part-1- of-3/

                 

                 

                C

                 

                 

                From: Astraport2012 <forums@adobe.com>

                 

                To: Ursica Claudiu <the_braniak@yahoo.com>

                Sent: Sun, October 3, 2010 3:07:57 PM

                Subject: Re: Warnings in FileReference - can not find the cause

                 

                 

                I found the solution to the first part of the warning. Only need to modify the

                object as ObjectProxy

                 

                public var elem:ObjectProxy = new ObjectProxy;

                 

                But with the second part is still a problem (warning: unable to bind to property

                'name' on class 'flash.net::FileReference'

                warning: unable to bind to property 'data' on class 'flash.net::FileReference').

                 

                I do not fully describe the problem in the first message. The main application

                calls the component and passes it parameters. They cause errors.

                 

                It is this component photoThumb.mxml:

                 

                <?xml version="1.0" encoding="utf-8"?>

                 

                   width="120" height="110"

                   backgroundColor="#FFFFFF" backgroundAlpha="0"

                   rollOver="{controls.visible=true;}" rollOut="{controls.visible=false;}">

                <mx:Image source="@Embed('t1.png')" width="100%" height="100%" alpha="0"

                horizontalAlign="center" verticalAlign="middle"/>

                <mx:VBox width="100%" height="90" y="5" horizontalAlign="center" >

                <mx:Image source="{data.fr.data}" maxWidth="100" maxHeight="75"

                horizontalAlign="center" verticalAlign="middle" />

                </mx:VBox>

                <mx:Label text="{data.fr.name}" width="118" truncateToFit="false" bottom="0"

                textAlign="center" />

                <mx:VBox id="controls" visible="false" y="65" right="10" horizontalAlign="right"

                >

                <mx:Button label="X" click="parentDocument.clearPhoto(data)" fontSize="6"

                width="30" height="15" />

                </mx:VBox>

                </mx:Canvas

                • 5. Re: Warnings in FileReference - can not find the cause
                  Claudiu Ursica Level 4

                  Can you share your project? Or email it privately ?

                  C