Please review the documentation on creating custom components.
Measure() is called before updateDisplayList().  Overriding the width
setter is not recommended.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of toniabc
Sent: Wednesday, November 07, 2007 12:47 AM
To: [email protected]
Subject: [flexcoders] width and height problem when createing my own
component in FLEX

 

Hi!

I created my own component that extends UIComponent, that draws
rectangle shape.

I overrided the seter for width that when i set new width, the object
redraw itself.

When this is done, i check the witdh of the object, it returns me
old width for one action back.

I overrided measure function.

********************************************************
Some of the code:
********************************************************

private function render(_arg_w:Number = 20,_arg_h:Number = 20):void{
rectSprite.graphics.lineStyle(1); 
rectSprite.graphics.beginFill(cfill, 1); 
rectSprite.graphics.drawRect(0,0,_arg_w,_arg_h);
addChild(rectSprite);
//set mesaures
invalidateSize( );

}

override protected function measure( ):void
{
super.measure( );
measuredHeight = measuredMinHeight = rectSprite.height;
measuredWidth = measuredMinWidth = rectSprite.width;

}
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth,unscaledHeight);
}

[Bindable]
override public function set width(_arg_w:Number):void{
//change width if number is passed
if(_arg_w && rectSprite !== null){
rectSprite.graphics.clear();
render(_arg_w);

}else{
trace("no data inserted");
}

}

*********************************************************

Thanks for help,
Toni

 

Reply via email to