Simple way to create programmetic skin in Flex

Found the very good video on blog expertria under article Creating programmetic skin in Flex.

Edited the updateDisplayList function to create button with more than one notch.

override protected function updateDisplayList(uWidth:Number, uHeight:Number):void
{
super.updateDisplayList(uWidth,uHeight);
this.graphics.clear();

var color:uint = Number(this.getStyle(‘backgroundColor’));

var matrix:Matrix = new Matrix();
matrix.createGradientBox(uWidth,uHeight,Math.PI/2);
this.graphics.lineStyle(1,0×999999,0.3,true);
this.graphics.beginGradientFill(GradientType.LINEAR,[color,ColorUtil.adjustBrightness(color,-30)],[1,1],[0x00,0xff],matrix);

this.graphics.moveTo(0, 10)

//left-up curve
this.graphics.curveTo(0, 0 ,10, 0)
//up notch
this.graphics.lineTo(uWidth/2-5,0);
this.graphics.lineTo(uWidth/2,-5);
this.graphics.lineTo(uWidth/2+5,0);
this.graphics.lineTo(uWidth – 10, 0);

//right-up curve
this.graphics.curveTo( uWidth  ,  0  , uWidth, 10)

//right notch
this.graphics.lineTo( uWidth , uHeight/2-5);
this.graphics.lineTo(uWidth  + 5, uHeight/2);
this.graphics.lineTo(uWidth , uHeight/2 + 5);
this.graphics.lineTo(uWidth , uHeight-10);

//right-bottom curve
this.graphics.curveTo( uWidth , uHeight , uWidth – 10, uHeight);

//bottom notch
this.graphics.lineTo(uWidth / 2 + 5, uHeight)
this.graphics.lineTo(uWidth / 2 , uHeight + 5)
this.graphics.lineTo(uWidth / 2 – 5, uHeight)
this.graphics.lineTo(10, uHeight);

//left-bottom curve
this.graphics.curveTo( 0, uHeight ,0, uHeight – 10)
this.graphics.lineTo(0, 10)

this.graphics.endFill();
}

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: