5 Replies Latest reply on Jan 4, 2010 9:38 AM by nikos101

    Shared objects update the things they are bound to

    nikos101 Level 2

      Shared objects (my_so) don't seem to be update the things they are bound to

       

      <mx:Button toolTip="{(my_so.data.wantMusic)?'Turns off music':'Turns on music'}"
                     id="musicOn"
                     icon="{(my_so.data.wantMusic)?imgPlayClass:imgPlayOff}"
                     >

       

      When my_so.data.wantMusic changes the icon doesn't change

        • 1. Re: Shared objects update the things they are bound to
          saisri2k2 Level 4

          Try making everything [Bindable] the icon classes, my_so etc.,

           

          the icons should be like (bindable) the following.

           

          [Bindable]

          [Embed(source="/images/icn_create.gif")]

          public static var icnAdd:Class;

           

           

          and finally see if you are gettin the right object and its properties by debugging the app.

          • 2. Re: Shared objects update the things they are bound to
            nikos101 Level 2

            I've done this:

             

                [Embed(source="../images/48px-Crystal_Clear_app_knotify.png")]

                           

                            private var imgPlayOff:Class;

             

            [Embed(source="../images/48px-Crystal_Clear_app_knotify_on.png")]

                           

                            private var imgPlayClass:Class;

             

            I've tried debugging but when the shared object gets changed the logic code

            to change the icon doesn't get called

             

            best wishes

             

            Nikos

            • 3. Re: Shared objects update the things they are bound to
              nikos101 Level 2

              I've also done the following:

               

                     

                              private var my_so:SharedObject;

               

              maybe I also need to make the   my_so.data bindable as well so that the

              following code works as well?

               

               

              <mx:Button toolTip="{(my_so.data.wantMusic)?'Turns off music':'Turns on

              music'}"

                             id="musicOn"

                             icon="{(my_so.data.wantMusic)?imgPlayClass:imgPlayOff}"

                              cornerRadius="9" fillAlphas="[1.0, 1.0]"

              fillColors="[#0FEFBD, #7106D5]" width="26">

               

                      <mx:click>

                              <![CDATA[

                                  my_so=SharedObject.getLocal("mediaCenter");

                                  if (my_so.data.wantMusic)

                                  {

                                      stopIntroSound();

                                      my_so.data.wantMusic=false;

                                      my_so.flush();

                                  }

                                  else

                                  {

                                      playIntroSound();

                                      my_so.data.wantMusic=true;

                                      my_so.flush();

                                  }

               

                              ]]>

                          </mx:click>

                  </mx:Button>

               

              best wishes

               

              Nikos

              • 4. Re: Shared objects update the things they are bound to
                msakrejda Level 4

                The data property on a SharedObject is just an Object, which is not bindable. There is no direct way to propagate updates from it. FlexBuilder or mxmlc should give you a warning to that effect. It's hard to suggest a workaround without knowing what you are trying to do.

                • 5. Re: Shared objects update the things they are bound to
                  nikos101 Level 2

                  Maybe this could be my problem:

                   

                  Using the Bindable metadata tag

                   

                  When a property is the source of a data binding expression, Flex

                  automatically copies the value of the source property to any destination

                  property when the* source property* changes. To signal to Flex to perform

                  the copy, you must use the metadata tag to register the property

                  with Flex, and the source property must dispatch an event.

                  the shared object doesn't seem to have that property. I'm not sure how to

                  change the icon as there doesn't seem to be a setter for it on the button.

                   

                  best wishes

                   

                  Nikos