Question

I am trying to add a different icon each of my buttons. I have my skin file ready but not sure if I have to create a different skin class for each button. It sounds inefficient. Any suggestions?

<s:Button id="pass"
    width="110"
    height="35"
    fontWeight="bold" 
    fontSize="12" 
    fontFamily="arial" 
    label="Past Track" 
    click="pass_clickHandler(event)" 
    skinClass="skins.CustomSkin"/>      
<s:Button id="future" 
    width="110"
    height="20"
    fontWeight="bold" 
    fontSize="12" 
    fontFamily="arial" 
    label="Future Plan"
    click="future_clickHandler(event)"
    skinClass="skins.CustomSkin"/>

The skin:

<!-- layer 2: fill -->
<!--- @private -->
<s:Rect id="fill" left="1" right="1" top="1" bottom="1" radiusX="2">
    <s:fill>
        <s:LinearGradient rotation="90">
            <s:GradientEntry color="#304fd7" 
                             color.over="#4b6bf6" 
                             color.down="0xAAAAAA" 
                             alpha="0.85" />
            <s:GradientEntry color="#1f38a3" 
                             color.over="#3653cf" 
                             color.down="0x929496" 
                             alpha="0.85" />
        </s:LinearGradient>
    </s:fill>
</s:Rect>

<!-- icon --> // I could add my icon here but that would make me create  
              // a different icon image for different button
Was it helpful?

Solution

It is not built in, but a few folks have created components that support icons in Spark Buttons:

http://themorphicgroup.net/blog/?p=83
http://www.andymcintosh.com/?p=179

OTHER TIPS

Install 10.2 Flash Player and stable Hero SDK (4.5.0.19786). You can then use the icon property of the Spark Button.

http://labs.adobe.com/downloads/flashplayer10.html http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero

Note for your project you will have to specifically target player version 10.2.0. Unless its an issue with my environment, using the 'Use minimum version required by the Flex SDK' option in the project compiler settings of Flash Builder doesn't work with this 'stable' sdk. I don't get why things like this fail to behave as you think they should. If anyone knows where FB finds this minimum player version please chime in. I see the following in the flex-config.xml file (inside frameworks folder of sdk):

<!-- Specifies the minimum player version that will run the compiled SWF. -->
<target-player>10.2.0</target-player>

Flash Builder seems to ignore this, as its still trying to look in the libs/player/10.1 folder when using the minimum required version setting in the project properties. This is a major pain point with Adobe, and it seems every release introduces minor gotchas that will eventually frustrate people to the point of abandoning flash as a viable platform to develop with. If there is a fix for this adobe, please help us out and post it here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top