Aha! Could have sworn I'd tried that, but you're right. And it's the
holder class, not the top-level one that needs to be a Canvas.
Many thanks! I should have known this.
On Sun, Jun 1, 2008 at 4:20 PM, Josh McDonald <[EMAIL PROTECTED]> wrote:
> My Bad buddy, sorry!
>
> UIComponent.addChild is an inherited Flash thing, not part of Flex, and when
> you use it if it works at all, things don't go into Flex's display tree
> properly, and all sorts of pain ensues. Try extending Canvas instead of
> UIComponent. The magic you need lives in Container.
>
> -J
>
>
> On Sun, Jun 1, 2008 at 7:31 AM, Richard Rodseth <[EMAIL PROTECTED]> wrote:
>>
>> I'd love to wrap up this task. Does anyone have any other suggestions?
>>
>> On Tue, May 27, 2008 at 8:24 PM, Richard Rodseth <[EMAIL PROTECTED]>
>> wrote:
>> > I'm afraid I'm still struggling with this. The classes below work
>> > (more or less) if I supply a large button as "content", but if I try a
>> > VBox it appears to shrink to nothing. Any ideas? Hopefully the
>> > formatting survived.
>> >
>> > <view:ScaleOrCenterView width="100%" height="100%" >
>> > <mx:VBox borderStyle="solid" borderColor="red"
>> > horizontalScrollPolicy="off" verticalScrollPolicy="off">
>> > <mx:Button label="Test" width="400" height="400"/>
>> > </mx:VBox>
>> > </view:ScaleOrCenterView>
>> >
>> >
>> > [DefaultProperty("content")]
>> > public class ScaleOrCenterView extends UIComponent
>> > {
>> > private var _contentHolder:ScaleToFitContentHolder = new
>> > ScaleToFitContentHolder();;
>> > private var _content:UIComponent;
>> >
>> > public function ScaleOrCenterView()
>> > {
>> > super();
>> > }
>> >
>> > override protected function createChildren():void {
>> > super.createChildren();
>> > this.addChild(_contentHolder);
>> > }
>> >
>> > [Inspectable]
>> > public function set content(value:UIComponent):void {
>> > if (_content != null) {
>> > _contentHolder.removeChild(_content);
>> > }
>> > _content = value;
>> > if (_content != null) {
>> > _contentHolder.addChild(_content);
>> > }
>> > this.invalidateSize();
>> > }
>> >
>> > override protected function updateDisplayList(unscaledWidth:Number,
>> > unscaledHeight:Number):void
>> > {
>> > super.updateDisplayList(unscaledWidth, unscaledHeight);
>> >
>> > var contentWidth:Number = _content.getExplicitOrMeasuredWidth();
>> > var contentHeight:Number = _content.getExplicitOrMeasuredHeight();
>> >
>> > var xScale:Number = (unscaledWidth / contentWidth);
>> > var yScale:Number = (unscaledHeight / contentHeight);
>> >
>> > _contentHolder.setActualSize(unscaledWidth, unscaledHeight);
>> >
>> > _contentHolder.allowInvalidateSize = false;
>> > if (xScale < 1 || yScale < 1) {
>> > _contentHolder.scaleX = xScale
>> > _contentHolder.scaleY = yScale
>> > } else {
>> > _contentHolder.scaleX = 1.0;
>> > _contentHolder.scaleY = 1.0;
>> > }
>> > _contentHolder.allowInvalidateSize = true;
>> >
>> > }
>> >
>> > }
>> >
>> > public class ScaleToFitContentHolder extends UIComponent
>> > {
>> > public var allowInvalidateSize:Boolean = true;
>> >
>> > public function ScaleToFitContentHolder()
>> > {
>> > }
>> >
>> > override protected function measure():void
>> > {
>> > super.measure();
>> > }
>> >
>> > override public function invalidateSize():void
>> > {
>> > if (allowInvalidateSize)
>> > super.invalidateSize();
>> > }
>> >
>> > }
>> > 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
>> >>
>> >>
>> >>
>> >> ________________________________
>> >>
>> >
>
>
>
> --
> "Therefore, send not to know For whom the bell tolls. It tolls for thee."
>
> :: Josh 'G-Funk' McDonald
> :: 0437 221 380 :: [EMAIL PROTECTED]
>