flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arne Broedel <arne.broe...@googlemail.com>
Subject Re: Resizable Component that manages to keep its proportions
Date Thu, 15 Aug 2013 22:33:13 GMT
thank you


2013/8/16 Alex Harui <aharui@adobe.com>

> Measure() would be called whenever invalidateSize() is called, which is
> not just when added to the container.  But you are right that
> invalidateSize() isn't called when width or height is set.  You could use
> event handlers or override the setters.
>
> Sounds like you got it working though.
>
> On 8/15/13 2:58 PM, "Arne Broedel" <arne.broedel@googlemail.com> wrote:
>
> >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 <aharui@adobe.com>
> >
> >> 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" <arne@trainon.net> 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
> >>
> >>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message