I have created a simple button skin that has rounded corners that I want to
look like a pill-button.  I want it to work no matter how large or small the
button is.  The main visual object in the skin is of course a <Rect> object
that I will have to set the radius parameters on to round out the button. To
get this to work, you need to be able to get the size of the button that is
applied to the parent, and then apply those dimensions to the <Rect> in the
skin.  I thought that I could use the "parent" property to get the width and
height of the button that I was placing the skin on, but this is
unfortunately not working.  The skin code looks like the following:

<?xml version="1.0" encoding="utf-8"?>
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009"; 
                                   xmlns:s="library://ns.adobe.com/flex/spark" 
                                   
xmlns:fb="http://ns.adobe.com/flashbuilder/2009";
                                   minWidth="20" minHeight="20" 
                                   alpha.disabled="0.5" 
xmlns:fxgAssets="fxgAssets.*"
creationComplete="init(event)">
        
        <fx:Metadata>
                
        </fx:Metadata>
        <fx:Script>
                
        </fx:Script>
        
        
        
        <s:states>
                <s:State name="up" />
                <s:State name="over" />
                <s:State name="down" />
                <s:State name="disabled" />
        </s:states>
        
        <s:Rect id="buttonRect" width="100%" height="100%">
                <s:fill>
                        <s:SolidColor color.up="#323233" color.down="#2B8D00"/>
                </s:fill>
        </s:Rect>
        <s:Label id="labelDisplay" color="#FAFAFA" horizontalCenter="0"
verticalCenter="0"/>
        
</s:SparkButtonSkin>


You can see that in the init() method on creationcomplete, I trace out
this.parent.height which is tracing 41 pixels, but the actual height of the
button is tracing out as 61.44 pixels, so using "parent" to get the
dimensions of the parent component is not working and is giving an
undesireable number.  How can I go about getting the X and Y dimensions of
the button component from within the skin so that I can apply the correct
radius values to the <Rect> in my skin??

Thanks for any thoughts or guesses at all.



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/

Reply via email to