2 Replies Latest reply on Aug 15, 2007 9:13 PM by Roadman730

    Adjust percentWidth of Customized UIComponent

      I would like to create my own UIComponent.
      There will be some drawing using "drawRect" of flash.display.Graphics class.
      I would like to know how to get the "percentWidth" of my own UIComponent works? I have set the percentWidth the UI instances but no effect at all.

      Or is there other drawing way to make the "precentWdith" of customized component work?
        • 1. Re: Adjust percentWidth of Customized UIComponent
          Hi -- I'm not exactly sure what you are asking, perhaps you could rephrase your questoin, and include some *small* code examples? I'll take a stab at it though :)

          percentWidth is a value on child UIComponents like yours, but is _used_ by the parent (e.g. containers) for layout and sizing of that child. If your component is not in a container like an HBox, then the value is unused.

          If your component is inside of a container, and you are saying that you set the percentWidth on your component, and it is not doing anything, then I might suspect that:
          * You are not reading the width/height of your component when doing your drawing -- look at width/height, unscaledWidth/Height, and measuredWidth/Height.
          * You're giving it improper values -- it takes Numbers from 0 to 100
          * You're setting the width or explicitWidth elsewhere, which makes the percentWidth meaningless.

          Hope some of that helps,
          • 2. Adjust percentWidth of Customized UIComponent
            Roadman730 Level 1
            I have create a UIComponent RectObj wiht a draw( ) method.
            A rectange will be drawn inside the draw( ) method. I put this RectObj inside a container Convas.
            How can I make the width & height of RectObj be relative to the Convas..

            i want to make it as:

            var rect: RectObj = new RectObj();
            rect.percentWidth = 100;
            rect.percentHeight = 100;
            var con : Convas = new Convas();