I think I figured it out, or at least found a workaround.  When I was tracing
out the button dimensions in both the original button and on the skin, the
skin value was tracing out BEFORE the button value, and of course giving an
erroneous value.  I believe that because of the way that I manually lay out
the display objects in my app, the creationComplete event in the skin was
firing BEFORE the width and height of the actual button were being set.  So
I stopped using creationComplete on the skin, and switched to updateComplete
and then all of the width/height dimensions started tracing out correctly
and the <Rect> component started to draw correctly.

The only other problem I ran into is that I could SEE the button redraw
itself an instant after it displayed which looked unprofessional, so I used
setTimeout to give it 100 ms before I made the skin visible.  Now it looks
perfect.  So my final skin code looks like this:

<?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.*"
updateComplete="sizeRect(event)" visible="false">
        
        <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>



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

Reply via email to