1 Reply Latest reply on Nov 9, 2009 7:53 PM by susrut316

    Applying Transform Matrix

    mcg135
      I am applying a transform matrix to a UIComponent. The width of the object changes appropriately when displayed; however, the width property on the component is 0. Does anyone know why the width property is not updated? Is the only way to retrieve the actual width through the transform matrix? I used the following code snippet.
      Thanks for any input!
      -Kris

      var comp:UIComponent = new UIComponent();
      comp.graphics.lineStyle(3);
      comp.graphics.drawRect(0,0,200,200);
      this.addChild(comp);
      trace("width before applying matrix = " + comp.width); // width = 0
      var matrix:Matrix = new Matrix();
      matrix.a = 2;
      comp.transform.matrix = matrix;
      trace("width after applying matrix = " + comp.width); // width still = 0 Why not 400?
        • 1. Re: Applying Transform Matrix
          susrut316

          I think we need to set the dimensions of the UIComponent as well. Check whether the code below works

           

          var comp:UIComponent = new UIComponent();
          comp.graphics.lineStyle(3);
          comp.graphics.drawRect(0,0,200,200);

          comp.width = 200;

          comp.height = 200;
          this.addChild(comp);
          trace("width before applying matrix = " + comp.width); // width = 200
          var matrix:Matrix = new Matrix();
          matrix.a = 2;
          comp.transform.matrix = matrix;
          trace("width after applying matrix = " + comp.width); // width still = 200