jason
jason

Reputation: 1631

set specific corner radius on VBox

by default, if set cornerRadius on VBox, all four corners will be effected. How to apply cornerRadius only to bottom-left and bottom-right?

Upvotes: 0

Views: 814

Answers (3)

Mahesh Parate
Mahesh Parate

Reputation: 786

Try this: - modify above code like this (code by -- user1367714)

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <local:stackOverflowCornerRadious x="50" y="50" width="200" height="200"/>
</s:Application>

ClassName: - stackOverflowCornerRadious

package
{
    import flash.display.Sprite;

    import mx.containers.Box;
    import mx.containers.VBox;
    import mx.utils.GraphicsUtil;

    import spark.primitives.Rect;

    public class stackOverflowCornerRadious extends VBox
    {
        public function stackOverflowCornerRadious()
        {
            super();
        }

        override protected function updateDisplayList(unscaledWidth:Number, 
                                                      unscaledHeight:Number):void 
        {

            super.updateDisplayList(unscaledWidth, unscaledHeight);

            graphics.clear();
            graphics.beginFill(0x00FF00);
            GraphicsUtil.drawRoundRectComplex(graphics,0,0,unscaledWidth,unscaledHeight,0,0,10,10)
            graphics.endFill();

        }


    }
}

Upvotes: 2

Ankur Sharma
Ankur Sharma

Reputation: 538

in flex3, i'd have used the borderskin instead of extending VBox. but i suggest you to go for flex4(my opinion).

==============================================================================

In flex4,

you have to use the skin class, and s:Rect has a property with which you can apply different corner radius to all four corners.

check out this link:

http://blog.flexexamples.com/2009/10/11/setting-a-corner-radius-on-individual-corners-on-a-rect-in-flex-4/

You can use BorderContainer with vertical layout.

VGroup is also there as of VBox , but that doesn't support skinning.(i mean no skinClass property defined)

<s:VGroup skinClass=""/>----not defined 
<s:BorderContainer skinClass="bcSkin"/>----defined, apply custom skin

SO BorderContainer is gud 1 with vertical Layout.

Thanks

Ankur

Upvotes: 2

Vaibhav
Vaibhav

Reputation: 1477

Extend the VBox component and override updateDisplayList method as mentioned below :-

override protected function updateDisplayList(unscaledWidth:Number, 
       unscaledHeight:Number):void 
{

   super.updateDisplayList(unscaledWidth, unscaledHeight);

   var cornerRadius:Number = getStyle("cornerRadius");
   var backgroundColor:int = getStyle("backgroundColor");
   var backgroundAlpha:Number = getStyle("backgroundAlpha");
   graphics.clear();

   // Background
   drawRoundRect(0, 0, unscaledWidth, unscaledHeight, 
       {tl: 0, tr: 0, bl: cornerRadius, br: cornerRadius}, 
       backgroundColor, backgroundAlpha);


}

Upvotes: 5

Related Questions