0 Replies Latest reply on Nov 24, 2011 4:46 PM by numba1john

    Sending ArrayCollections via P2P Flex

    numba1john

       

       

      I have a question regarding P2P with flex. When passing data between two applications using P2P. I get the following error:

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

       

      I've spent a few days using Google to try and find a solution, but a can't get rid of that error. I've tried using ObjectUtils, direct assignment, and creating a new ArrayCollection WITH the ObjectUtils inside the parenthesis and still can't solve the problem.


      Purpose of code:
         -> Two users connect via P2P
         -> 1st user can rearrange pictures (stored as objects in the array collection).
         -> 1st user sends updated ArrayCollection (with changed pictures) to 2nd user
         -> 2nd user's ArrayCollection gets updated and now sees manipulated pics

      As far as my knowledge of Flex goes (fairly new to it), I properly Binded what needed to be binded. Using pop-ups and trace, I was able to see that the data from the ArrayCollection gets copied in properly, but it just doesn't want to display.

       

      Example:

         Default "taken" (pictures) ArrayCollection

              1: sky

              2: bird

              3: sun

       

         User1 changes "taken" ArrayCollection order like:

              1: bird

              2: sky

              3: sun

       

          User 2 original/default "taken" ArrayCollection

              1: sky

              2: bird

              3: sun

       

           User 2 updated "taken" ArrayCollection

              1: bird

              2: sky

              3: sun


      Here are some snippets of my code:

      [Bindable] 
      public var taken:ArrayCollection = new ArrayCollection ([
              new picLayout(1,'sky.png'),
              new picLayout(2,'bird.png'),
              new picLayout(3,'sun.png')
          ])

      public function receiveSomeData(pass:ArrayCollection):void
      {
          // Want to replace current version of variable "taken" with
          // the one passed in using P2P
         this.taken= new ArrayCollection(pass.source);


      public function sendSomeData(free:ArrayCollection):void
      {
          sendStream.send("receiveSomeData",free);
      }

       

      Thank You for your help and time!