MXML skins are meant to be declarative. As in:
-I declare this label to be red
-I declare the background to be white.
But then, sometimes you can't declare it at compile time and need to figure it
out at runtime. Most of the time, binding expressions can be used as they are
also declarative:
-I want the label to be half way across the component: <label x="{width/2}" />
If you can use a binding expression, the binding subsystem should evaluate the
binding before the screen is refreshed.
In some cases, it is too much of a pain to create a binding expression. There
are often APIs you can override. I think ButtonSkin has an updateDisplayList
method.
HTH,
-Alex
On 12/27/19, 1:12 PM, "bilbosax" <[email protected]> wrote:
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="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fns.adobe.com%2Fmxml%2F2009&data=02%7C01%7Caharui%40adobe.com%7C886e37e5681f410ecc9b08d78b116d1e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637130779292453190&sdata=Fjtk4aAktSRr5p4JMV5lINa0vWTXoMtdh4zcrLar77U%3D&reserved=0"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fns.adobe.com%2Fflashbuilder%2F2009&data=02%7C01%7Caharui%40adobe.com%7C886e37e5681f410ecc9b08d78b116d1e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637130779292463185&sdata=kUBD0VwmTaWqoNO%2BvB1jq3OkIkCEtQONmg5%2FPJyDqH8%3D&reserved=0"
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:
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7C886e37e5681f410ecc9b08d78b116d1e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637130779292463185&sdata=yCCadE26g9zOH5mBKD9OkOUdMwbqJ2pxvjyZTu3FW4Y%3D&reserved=0