5 Replies Latest reply on Oct 15, 2008 8:43 PM by Newsgroup_User

    button skin

    Merlyn_MM
      I am trying to create a button with a png file and here is my code

      <mx:Button width="175" label="{myRepeater.currentItem.CATEGORYDESC}" data="{myRepeater.currentItem}" mouseOver="changeStyle(event)" upSkin="@Embed(source='{myRepeater.currentItem.ICON}')" click="displayId(event.target.getRepeaterItem())" mouseUp="categorySummarySelected(event.target.repeaterIndices[0])"/>
      upSkin="@Embed(source='{myRepeater.currentItem.ICON}')"

      but I am getting the following error: Implicit coercion of a value of type string to a type class.

      Thanks!
        • 1. Re: button skin
          cputnam14
          What does your PNG look like? If it is rectangular try this...
          <mx:Button id="mybttn"
          label="Click Me"
          overSkin="@Embed(source='PathToPNG/filename1.png')"
          upSkin="@Embed(source='PathToPNG/filename2.png')"
          downSkin="@Embed(source='PathToPNG/filename3.png')"/>

          If the PNG is a strange shape...like the shape of Texas...
          There is a little more to it. Let me know and I can walk you through the other way.
          • 2. Re: button skin
            Merlyn_MM Level 1
            If I give the file name it works but thats not what I am looking for. The file name is provided by the data provider and the button is inside a repeater. Each button has a different image file which is provided by myRepeater.currentItem.ICON


            <mx:Repeater id="myRepeater" dataProvider="{catInfo}">
            <mx:HBox id="bigbox">
            <mx:Image id="img" source="{myRepeater.currentItem.ICON}"/>
            <mx:Button width="175" label="{myRepeater.currentItem.CATEGORYDESC}" data="{myRepeater.currentItem}" mouseOver="changeStyle(event)"
            upSkin="@Embed(source='{myRepeater.currentItem.ICON}')" click="displayId(event.target.getRepeaterItem())" mouseUp="categorySummarySelected(event.target.repeaterIndices[0])"/>
            </mx:HBox>
            </mx:Repeater>


            Thanks!
            • 3. Re: button skin
              Level 7

              "Merlyn MM" <webforumsuser@macromedia.com> wrote in message
              news:gd5llm$3l3$1@forums.macromedia.com...
              > If I give the file name it works but thats not what I am looking for. The
              > file
              > name is provided by the data provider and the button is inside a repeater.
              > Each
              > button has a different image file which is provided by
              > myRepeater.currentItem.ICON
              >
              >
              > <mx:Repeater id="myRepeater" dataProvider="{catInfo}">
              > <mx:HBox id="bigbox">
              > <mx:Image id="img" source="{myRepeater.currentItem.ICON}"/>
              > <mx:Button width="175" label="{myRepeater.currentItem.CATEGORYDESC}"
              > data="{myRepeater.currentItem}" mouseOver="changeStyle(event)"
              > upSkin="@Embed(source='{myRepeater.currentItem.ICON}')"
              > click="displayId(event.target.getRepeaterItem())"
              > mouseUp="categorySummarySelected(event.target.repeaterIndices[0])"/>
              > </mx:HBox>
              > </mx:Repeater>

              An embed is just that. it _embeds_ the file. At compile time. I.e. the
              compiler has no idea what the value will be in your running file. You might
              want to look at my TileList_withStyleFunction to get some inspiration on how
              to handle this situation:
              http://flexdiary.blogspot.com/2008/08/tilelist-with-stylefunction.html


              • 4. Re: button skin
                Merlyn_MM Level 1
                Amy

                Thanks for your help. Since I do not know the image files upfront to embed them like in your example. This is what i did and its not correct. Can you please guide me further?

                private function styleFunction(repeaterItem:Object):Class{
                var btnIcon:Class = repeaterItem.ICON;
                return btnIcon;
                }

                <mx:Button width="175" label="{myRepeater.currentItem.CATEGORYDESC}" data="{myRepeater.currentItem}" mouseOver="changeStyle(event)"
                upSkin="@Embed(source=styleFunction(event.target.getRepeaterItem()))" click="displayId(event.target.getRepeaterItem())" mouseUp="categorySummarySelected(event.target.repeaterIndices[0])"/>
                upSkin="@Embed(source=styleFunction(event.target.getRepeaterItem()))"
                • 5. Re: button skin
                  Level 7

                  "Merlyn MM" <webforumsuser@macromedia.com> wrote in message
                  news:gd5uat$ec5$1@forums.macromedia.com...
                  > Amy
                  >
                  > Thanks for your help. Since I do not know the image files upfront to embed
                  > them like in your example. This is what i did and its not correct. Can you
                  > please guide me further?
                  >
                  > private function styleFunction(repeaterItem:Object):Class{
                  > var btnIcon:Class = repeaterItem.ICON;
                  > return btnIcon;
                  > }
                  >
                  > <mx:Button width="175" label="{myRepeater.currentItem.CATEGORYDESC}"
                  > data="{myRepeater.currentItem}" mouseOver="changeStyle(event)"
                  > upSkin="@Embed(source=styleFunction(event.target.getRepeaterItem()))"
                  > click="displayId(event.target.getRepeaterItem())"
                  > mouseUp="categorySummarySelected(event.target.repeaterIndices[0])"/>
                  >
                  > upSkin="@Embed(source=styleFunction(event.target.getRepeaterItem()))"

                  >

                  http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf

                  Q 11