views:

974

answers:

1

Hi, I have a degrafa surface into a canvas container. I want to link both width and height. When i use binding like it works as expected:

// binding
   BindingUtils.bindProperty(rect,"height",this,"height"); 
   BindingUtils.bindProperty(rect,"width",this,"width");

Now, someone told me that i should do it on validateSize() or updateDisplayList(), with my current knowledge of flex i dont realy know why but i tried the following

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

    trace(unscaledWidth, unscaledHeight);
    this.width = unscaledWidth;
    rect.width =unscaledWidth;
    this.height = unscaledHeight;
    rect.height = unscaledHeight;

}

The degrafa rectangle get resized well but not the 'this' canvas container. They seem to be not binded, did i miss something ?

Also i would like to modify a little bit the relation in rect.width = this.width with some factor in it which i cant do using the bindproperty method.

Thanks a lot for any clue.

A: 

Just in case,

some more code

public class RectangleShape extends BaseShape 
{
public function RectangleShape(fillColor:int) {
    super.name = shapeName;
    solidFill.color = fillColor;


    // shape
    solidFill.alpha = 0.3;
    rect.fill = solidFill;
    rect.stroke = solidStroke;    
    geoGroup.geometryCollection.addItem(rect);     
    geoGroup.target = surface;

    surface.graphicsCollection.addItem(geoGroup);  
    this.addChild(surface);

  // binding
  // BindingUtils.bindProperty(rect,"height",this,"height"); 
  // BindingUtils.bindProperty(rect,"width",this,"width"); 
}




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

    trace(unscaledWidth, unscaledHeight);
    this.width = unscaledWidth;
    rect.width =unscaledWidth;
    this.height = unscaledHeight;
    rect.height = unscaledHeight;

}
coulix