0 Replies Latest reply on Nov 1, 2007 4:16 AM by IamRaj

    A simple question on sprite or movie clip for center

    IamRaj
      I simply draw a line using AS3 in flash environment. but i used moveTo for center. but if i run this it is simply taking x,y axis 0,0 and move around. I want to move this from center of the stage. please help.

      below is my code

      var line:Sprite = new Sprite()
      addChild(line);

      var cx:Number = stage.stageWidth/2;
      var cy:Number = stage.stageHeight/2;

      var radius:Number = 1;
      var increase:Number = 0;

      line.graphics.lineStyle(1, 0xff00ff);

      line.addEventListener(Event.ENTER_FRAME, onEnter);

      function onEnter(event:Event):void
      {
      increase += radius;

      //trace(increase);
      //line.graphics.moveTo(cx, cy);
      line.graphics.lineTo(cx + increase, cy + increase);
      line.rotation += 0.1;
      }