0 Replies Latest reply on Jan 16, 2009 4:31 AM by slaks

    Transformation Problem

    slaks
      Hi,
      I need to transform world coordinate system into an arbitrary one.
      I have the working code in VB but the same code doesn't work in flex. Does somebody knows what is the problem?
      In this code the line must be drawn from bottom left corner to upper right corner.
      However nothing is drawn.
      var c:Sprite = new Sprite();

      var xMin:Number = -10;
      var xMax:Number = 110;
      var yMin:Number= -10;
      var yMax:Number = 110;

      var width:Number = xMax - xMin;
      var height:Number = yMax - yMin;

      var stageWidth:Number = stage.stageWidth;
      var stageHeight:Number = stage.stageHeight;

      var scaleX:Number = stageWidth / width;
      var scaleY:Number = stageHeight / height;


      var matrix:Matrix = new Matrix();
      //scale and translate to origin of the coordinate system
      matrix.createBox(scaleX,-scaleY,0,-xMin,yMax);
      c.transform.matrix = matrix;

      trace(c.transform.matrix);
      var line:Sprite = drawLine2(xMin,yMin,xMax,yMax);
      c.addChild(line);
      this.addChild(c);
      .....

      private function drawLine2(x1:Number,y1:Number,x2:Number,y2:Number) : Sprite {
      var line:Sprite = new Sprite();
      line.graphics.lineStyle(1,0x000000);
      line.graphics.moveTo(x1,y1);
      line.graphics.lineTo(x2,y2);
      return line;
      }