3 Replies Latest reply on Feb 3, 2011 1:07 PM by One_Life

    Binding Syntax Question

    One_Life Level 1

      Hi,

       

      Can you tell me what the "data:" does in the following binding expression:

       

            protected function vehiclerequestform1_vehicleRequestEventHandler(event:VehicleRequestEvent):void
            {
              vehicleService.addVehicleRequest({data:event.vehicleRequestData});
            }

       

      I'm not seeing data defined anywhere (in this working example), so I was curious what this does.

       

      Thanks

        • 1. Re: Binding Syntax Question
          Flex harUI Adobe Employee

          {} is also used as a literal to create an object.  IOW, that code is the

          same as:

           

          Var temp:Object = new Object();

          Temp.data = event.vehicleRequestData

          1 person found this helpful
          • 2. Re: Binding Syntax Question
            _spoboyle Level 4

            {} in this case creates an object and data: is declaring a property on this object assigned to event.vehicleRequestData

             

            this sort of thing is used a lot in tweening, you might want to take a look at anonymous objects

            1 person found this helpful
            • 3. Re: Binding Syntax Question
              One_Life Level 1

              I see, thanks.  So in this case the {} isn't a binding expression at all, but intead the creation of an anonymous object (as

              _spoboyle also pointed out), where the significant part is just assigning some object a property, in this case the "data" property?   I guess that's because the addVehicleRequest function expects some object with a data property, ... this function will check for that.