Here's what I ended up with, can someone tell me if it's the right way to do
it ?

 

public class MyButton extends Button

{

      private var highlight:UIComponent;

 

      public function MyButton():void

      {

            super();

            highlight = new UIComponent();

            addChild(highlight);

            }

 

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

      {

            super.updateDisplayList(unscaledWidth, unscaledHeight);

            

            setChildIndex(highlight, numChildren - 1);

 

            var cornerRadius:Number = getStyle("cornerRadius");

                  

            highlight.graphics.clear();

            highlight.graphics.beginGradientFill("linear", [ 0xFFFFFF,
0xFFFFFF ], [0, 0.40], null, verticalGradientMatrix(1, 1, unscaledWidth - 2,
(unscaledHeight - 2) / 2));

 
GraphicsUtil.drawRoundRectComplex(highlight.graphics,1,1,unscaledWidth-2,(un
scaledHeight-2)/2,cornerRadius-1,cornerRadius-1,0,0);

            highlight.graphics.endFill();

      }           

}

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Laurent Vitalis
Sent: 18 janvier 2007 13:47
To: [email protected]
Subject: [flexcoders] How to deal with icons in a custom button skin ?

 

Hi, i've started working in Flex 2 last month. I am unable to achieve
something I consider simple even after googling a lot and reading my 3 books
(as3 cookbook, flex2 training and as3 design patts.).

 

I want to code a button skin which will display a highlight OVER the button
icon and text.

 

I want my updateDisplayList to do the following :

 

-          draw the button background (drawRoundRect)

-          draw the icon

-          draw the text

-          draw the highlight (another drawRoundRect)

-          draw a shadow (RectangularDropShadow)

 

After looking at Button.as, I'm afraid that the component is not flexible
enough for this.

 

Thanks for your help.

Laurent.

 

__________ NOD32 1988 (20070118) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

Reply via email to