but the measure method will only be invoked when adding the object to a
container. So it wont work on resize, does it?
The only way I could get it working is this script in my Button-Skin:

                        protected function
sparkbuttonskin1_initializeHandler(event:FlexEvent):void
{
this.hostComponent.addEventListener("widthChanged",sizeChangeHandler);
this.hostComponent.addEventListener("heightChanged",sizeChangeHandler);
 }

 protected function sizeChangeHandler(event:Event):void
{
switch (event.type)
{
case "widthChanged":
if(this.hostComponent.height!=this.hostComponent.width*2)
{
this.hostComponent.height=this.hostComponent.width*2;
}
break;
case "heightChanged":
if(this.hostComponent.width!=this.hostComponent.height/2)
{
this.hostComponent.width=this.hostComponent.height/2;
}
 }

}

The propertyChanged Event, that I was trying to listen to in the first
place, is not dispatched by changing width and height. So it has to be
"widthChanged" and "heightChanged".
Moreover, and I dont know why, this only works on the hostComponent.


2013/8/15 Alex Harui <[email protected]>

> In theory, in the measure() method, you would set measuredWidth or
> measuredHeight based on explicitHeight and/or explicitWidth
>
> On 8/15/13 11:43 AM, "Arne Broedel" <[email protected]> wrote:
>
> >Hi Flex-Community,
> >I am skinning a Button with an icon. The Button should be sizable but keep
> >its proportions.
> >Its proportions width to height is 2 to 1. So every time the width is
> >changed the height shall change to width/2 and every time the height is
> >changed the width shall change to height*2.
> >Anyone can tell me a proper solution.
> >Thans
>
>

Reply via email to