Thanks for the tip. I have some work to do on preserving aspect ratios
and adding the centering capability, but the basic idea seems to work.

I created a content holder UIComponent, which overrides invalidateSize

            override public function invalidateSize():void
            {
                if (allowInvalidateSize)
                    super.invalidateSize();
            }

In the parent, I set the flag before and after adjusting the scale.
Since the content holder is itself a custom class, I suppose it would
be a little cleaner to add a public method to the content holder that
would do the scaling.

Simple, but gets the job done.

On Mon, May 26, 2008 at 9:02 PM, Alex Harui <[EMAIL PROTECTED]> wrote:
> One way is to block invalidateSize when scaling the child.  See
> ListBaseContentHolder
>
>
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED]
> On Behalf Of Richard Rodseth
> Sent: Monday, May 26, 2008 12:09 PM
> To: [email protected]
> Subject: [flexcomponents] Fwd: Center/Shrink To Fit
>
>
>
> I haven't done any more work on this, but I thought I'd see if the
> smaller flexcomponents list had any advice for me. I'm thinking maybe
> I should emulate SWFLoader and use a DisplayObject as "content
> container". Advice appreciated.
>
> ---------- Forwarded message ----------
> From: Richard Rodseth <[EMAIL PROTECTED]>
> Date: Fri, May 23, 2008 at 5:00 PM
> Subject: Re: Center/Shrink To Fit
> To: [EMAIL PROTECTED]
>
> Is there a way to set the scale of a component without triggering
> invalidateSize() ?
>
> My initial effort to create a "ScaleToFit" component involved setting
> scaleX and scaleY in updateDisplayList. But that results in some
> recursion. Perhaps this is the wrong place to set the scale.
>
> I notice that SWFLoader uses a DisplayObject as a content holder, but
> my attempts to cast "this" to DisplayObject before setting the
> property didn't help - the UIComponent version of "set scaleX" is
> still invoked.
>
> On Fri, May 23, 2008 at 7:37 AM, Richard Rodseth <[EMAIL PROTECTED]> wrote:
>> I'm looking to find or create a component which would scale (not
>> resize) its contents smaller if they were larger than this component's
>> bounds, and center them if they're smaller. I could imagine
>> extensions to support "expand to fit" as well, but that's not needed
>> currently.
>>
>> The "contents" can be a single child if that helps, or the full child
>> list of a container. I've done a bit of custom component development,
>> but would appreciate any suggestions/pointers for this scenario.
>>
>> Thanks in advance.
>>
>
> 

Reply via email to