Monday, September 17, 2018

Basic Loop Usage for actionscript3 tutorials

ad300
Advertisement

Basic Loop Usage

If it wasn't for loops you would have to repeat a statement multiple times if you want to have an action executed more than once. For example, say that you want to create ten Movie Clips and add them to the display list. The long way for doing this would have been to type the command ten times:
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
addChild(new MovieClip());
However, you can do the same exact thing using a loop without having to type the same code multiple times:
for (var i:Number=1; i<=10;i++){
addChild(new MovieClip());
}
This second code generates the same exact result, but in a much more compact way. Using a loop also makes it less likely for you to have typing errors because you type the code once and then it is automatically repeated.
There are five different loop types, we are going to explain how to create each of them in turn.

click here for loop
Share This
Previous Post
Next Post

Pellentesque vitae lectus in mauris sollicitudin ornare sit amet eget ligula. Donec pharetra, arcu eu consectetur semper, est nulla sodales risus, vel efficitur orci justo quis tellus. Phasellus sit amet est pharetra

0 comments:

Ad Section2

Sponsor

Ad Section