Looping Statements

  • With a looping statement you can create an action or a set of actions that repeat. And you can set a limit of repeats
  • First you have to create a variable that tracks the number of loops:
    • var i:int = 0;
      while ( i < 120 ) {
      }
  • then you need to increase the count
    • i+=10;
  • Try this:
    • var i:int = 0;
      while (i<361){
      var myShape:Shape = new Shape();
      myShape.graphics.lineStyle(1);
      myShape.graphics.drawEllipse(0,0,200,90);
      addChild(myShape);
      myShape.x=200;
      myShape.y=200;
      myShape.rotation = i;
      }
    • What happens?
    • What's missing?
< >