1.)Loops
are a way of repeating commands. You can tell a program
to repeat a function, increase a variable several times,
or something simple as tell the program to do anything
several times. Here is an example. You can test by pasting
the code into a frame of an actionscript 3.0 document.
|
2.)
Here is the code;
var
myString:String = "repeat";
for(var a:int = 0; a < 10; a++){
trace(myString);
}
You can tell the program. How many times you want the
program to loop though. There are other ways to program
a loop. Such as using a "while function", or a "do"
statement... A while function requires if statements
and I will show you how to program those later on. A
do loop requires you to have an array. I will also show
you how to program Arrays later on. Ok here is the break
down of a for loop. First you must tell the program
what kind of loop this is. Then you must tell the program
what kind of variable you are going to count by. In
this case I have chosen an int type. Then part 2 requires
you to tell the program how many times you are going
to loop it though, in this case I have chosen (while
the int is less than 10). Then the third statement tells
the program what to count by. In this case I have chosen
to add 1 incriment each time the program has looped
through. The Next Part is to add the opening and closing
braces, and inside the opening and closing braces is
what is going to be looped through. In this case I have
chosen a trace statement of the variable myString.
|