5 Replies Latest reply on Sep 24, 2008 7:41 PM by Newsgroup_User

    button fillColors

    Merlyn_MM Level 1
      Here I am again, probably I am again doing something I am not supposed to do but I am still learning. Here is my code, I am trying to set the fillcolrs dynamically but its giving an error saying 1067:implicit coercion of a value of type string to an unrelated type Array. Someone please tell me what am I doing wrong?

      Thanks!

      <mx:Repeater id="myRepeater" dataProvider="{catInfo}">

      <mx:VBox id="bigbox">
      <mx:Button label="{myRepeater.currentItem.CATDESC}"
      data="{myRepeater.currentItem}" fillColors="{myRepeater.currentItem.FILLCOLOR},{myRepeater.currentItem.FILLCOLOR}"
      click="displayId(event.target.getRepeaterItem())" mouseUp="categorySummarySelected(event.target.repeaterIndices[0])">
      </mx:Button>
      </mx:VBox>
      <mx:VBox id="summary">
      <mx:Repeater id="myrep" dataProvider="{SubcatInfo1}">
      <mx:Label text="{myrep.currentItem.CATDESC}" />
      </mx:Repeater>
      </mx:VBox>
      </mx:Repeater>
        • 1. Re: button fillColors
          Level 7

          "Merlyn MM" <webforumsuser@macromedia.com> wrote in message
          news:gbe0b1$b3u$1@forums.macromedia.com...
          > Here I am again, probably I am again doing something I am not supposed to
          > do
          > but I am still learning. Here is my code, I am trying to set the fillcolrs
          > dynamically but its giving an error saying 1067:implicit coercion of a
          > value of
          > type string to an unrelated type Array. Someone please tell me what am I
          > doing
          > wrong?
          >
          > Thanks!
          >
          > <mx:Repeater id="myRepeater" dataProvider="{catInfo}">
          >
          > <mx:VBox id="bigbox">
          > <mx:Button label="{myRepeater.currentItem.CATDESC}"
          > data="{myRepeater.currentItem}"
          > fillColors="{myRepeater.currentItem.FILLCOLOR},{myRepeater.currentItem.FILLCOLOR
          > }"
          try
          fillColors="[{myRepeater.currentItem.FILLCOLOR},{myRepeater.currentItem.FILLCOLOR}]"


          • 2. Re: button fillColors
            ntsiii Level 3
            For repeating components even moderately complex, as is yours, you should put all of the repeated content into a custom component and repeat that.

            Pass in the entire current item, say to a property "data".
            <mx:Repeater id="rp" >
            <MyComp data="{rp.currentItem}" />
            </mx:Repeater >

            Then in your component, the code is simplified to:
            fillColors="[{data.FILLCOLOR},data.FILLCOLOR}]"

            Lots of other benefits, such as setting up events, and accessing the "data" property from a handler.

            Tracy
            • 3. Re: button fillColors
              Merlyn_MM Level 1
              tried both ways but ended up with the same error. Any other ideas?

              Thanks!
              • 4. Re: button fillColors
                ntsiii Level 3
                Ok, implement the "data" property as a setter function.

                Declare a bindable instance var as an array, and bind the fillColors to that array: fillColors="{aFillColors}"

                In the setter function assign the array elements:

                aFillColors = [data.FILLCOLOR,data.FILLCOLOR]

                This will let you step into the setter function if necessary to debug it.

                Note that you can't simply use setStyle in the setter function because it may run before creationComplete and your child components will not yet exist. Binding is one way around this.

                Tracy
                • 5. Re: button fillColors
                  Level 7

                  "ntsiii" <tspratt@lariatinc.com> wrote in message
                  news:gbelqv$551$1@forums.macromedia.com...
                  > Ok, implement the "data" property as a setter function.
                  >
                  > Declare a bindable instance var as an array, and bind the fillColors to
                  > that
                  > array: fillColors="{aFillColors}"
                  >
                  > In the setter function assign the array elements:
                  >
                  > aFillColors = [data.FILLCOLOR,data.FILLCOLOR]
                  >
                  > This will let you step into the setter function if necessary to debug it.
                  >
                  > Note that you can't simply use setStyle in the setter function because it
                  > may
                  > run before creationComplete and your child components will not yet exist.
                  > Binding is one way around this.

                  Or you can override updateDisplayList. I think that's where the great
                  engineers in the sky intended us to set visual properties.