Hey, I’m new to the forums and Flahs itself. Well, I’ve always have been interested in Flash, just never got into it as much as now and I must say I really enjoy it alot. I recently got a book and got to the chapters which covers loops. I first explained the motion tween loops, thats ofcourse is self explanatory, the it covered the scripted loops. Here is where i got messed up. They show an example it looks something like this :
its just adding each of those clips in the array for future reference. In that script alone, theres no advantage, but it would supposedly lead to easier management of the clips further down the road :-\
One thing to be aware of though, newbieMX, is how lostinbeta corrected the eval statement replacing * with "
Well, the code doesn’t matter, the book was just giving me an example of what the “for” code looked like. That’s what i need explained to me… I need to know how the for loop works… if you can help , please help :-\
yes, sorry about that, by mistake i guess i clicked on post new thread, sorry… (please someone explain to me how the for loop works thx, if u could give me a script example to see how it works would be greatly appreciated)
this is just for the for loops, not the arrays in case you needed that too… so heres for loops
the syntax is basically
for(initialize variable, set upper limit, count by what)
{
code…
}
for(i=0; i <= 5; i++)
it starts your variable i, while its less than or equal to 5 it will keep going, and each time it runs through a loop it will increment by 1.
for(i=0; i <= 5; i += 2)
this wouuld do the same thing except it would increment i by 2
this would only go three times though… (0, 2, 4, 6) when it gets to 6 it will have met the exit condition (i <= 5) because its not less than five, and its not equal to it, so it stops looping.
yes, it helps tremendously.thx alot man. Now one more question regrading loops… how would it look like if you were looping a movie clip? and is it possible, and what would happen if it does, for example, what would looping a movie clip be good for? I ask this because I have heard you can do this with mc’s…
looping with mc’s is just a loop that happens every time it enters a frame. you do this by selecting your mc, going to actions and putting your code within the header:
onClipEvent(enterFrame)
{
code…
}
this will make the code happen each time it runs a frame
onClipEvent(load)
this can be used to initialize variables… it runs it only once, when the clip is loaded on the stage
:-\ I’m not sure if I’m just not good with flsh Scoot, but I kinda get it and don’t at the same time. I only have a week with Flash and learning alot from the book. Hmm… if i can ask you for a favor… is it possible to show me an example of using the loop with a movieClip? If so thx alot !:beam:
here is a small example, there is much more you can do with it though… this fla is just scripted movement… in the load part it initializes the speed, and in the loop it move the mc across the stage.
Thx man! But that wasen’t the sorta loop I was referig too… I was refering to a scripted loop. I want to know how the (for) loop works with a movie clip. But thanx man I really appreciate the help
Oh man, thx alot! Now I do get it, plus you included the duplicateMovieClip in it, so makes it double the thx! I’ll study your code further I saw you included random y, x! So I will experiment with it and make some kind of animation. Well thx alot man, you really helped =)
if you get stuck on anything another good place to look if you have it is the actionscript library… it tells you parameters for functions and stuff and is pretty helpful sometimes… just go to the help menu and then actionscript dictionary… then just look up what you need… glad i helped