Scripted loops

can I ask an additional question:

how can I use a button to control the movement of the ball in the downloadable loop.fla?

It would be good if I could use a button to start the movement which would then be stopped by an upper limit in a loop for example

Hey scoot, with a brief explanation from you and my little knowledge of actionscripting, I made this stupid little sig ^_-. I have one more question about loops, this is the code that i used

onClipEvent(EnterFrame) {
for(i=0; i<20; ++i; ){
scale=Math.random()*100;
this.x_scale=scale;
this.y_scale=scale;
this._alpha=Math.random()*100;
this._x=Math.random()*100;
this._y=Math.random()*400;
}
}

Now if you were to try this code, they would be a bunch of square or whatever object you’re duplicating all around the place with different _alpha . Now how would I make it so that it wouldnt be so quick at changin? Is there some way to change the speed so the duplicated object appears more slowly? For instance I made a tweened animation and I just want it duplicated and in different places of the movie, how would I do it so it does the whole tweened movie is seened? If you can help plz do :wink:

jimw00d: I have no clue what you mean, check my attachment, is that anywhere close? You should start a new thread with this problem. If you already did, then please don’t crosspost, but since you did already, can you post a link to that thread?

newbieMX: I don’t wanna rain on your parade or anything, but your footer is way too big. The footer requirements can be found here…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=16926

Oops, the attachment MIGHT help :wink:

Lost.

I was thinking more along these lines…

Fla attached.

But I can’t figure out how to return the red block to its original position when the loop has finished.

thanks for helping on this one though, no one else seemed remotely interested

Like this?

well almost but I only want the block to return when the button is pressed for a second time.

Can I make a button do two different things depending on whether it has or hasn’t been pressed before.

If I have two buttons:

One button-enter site
Second-read text

1 User presses enter site button- block slides in from left as in file, maybe one colour

2 Or user presses read Text button-block slides in with a different colour (I can handle this with a setRGB thing)

3 Then having read text, user decides to enter site and presses enter button, at this point I want the same box to slide in with the same colour as step 1

I guess we are close, well you more than me.

Have I explained myself?

Alright, how about this then.

newbieMX…

onClipEvent(EnterFrame) {
for(i=0; i<20; ++i; ){
scale=Math.random()*100;
this.x_scale=scale;
this.y_scale=scale;
this._alpha=Math.random()*100;
this._x=Math.random()*100;
this._y=Math.random()*400;
}
}

this is your code and you want it to run slow enough for people to see… well for one… if you are doing a frame loop… you shouldnt have a for loop inside it. the for loop will do everything in one frame… making it all done at once. if you want it to happen one frame at a time take the for loop out… and i noticed an error in your code

this.x_scale=scale;
this.y_scale=scale;

should be

this._xscale = scale;
this._yscale = scale;

(underscore goes before xscale and yscale)

if you want it to go even slower than 1 time every frame… you can 1) slow down the frame rate or 2) do it with a variable and only do the frames with a factor of a certain number

to do that you would have to use the modulous operator (the percent sign) say you do 10 % 2… it will divide 10 by 2 and then return the remainder. if 2 goes in evenly then it returns 0. you can use this to check if you go into a frame say every 2 times…

example for your code:


onClipEvent(load){
counter = 0;
}

onClipEvent(EnterFrame) {
counter ++;
if(counter % 2 == 0)
{
scale=Math.random()*100;
this._xscale=scale;
this._yscale=scale;
this._alpha=Math.random()*100;
this._x=Math.random()*100;
this._y=Math.random()*400;
}
}

hope this helps

Once again scoot you have been of great help :wink: ! I will experiment with the code further. Thx alot man:beam:

*Originally posted by lostinbeta *
**newbieMX: I don’t wanna rain on your parade or anything, but your footer is way too big. The footer requirements can be found here…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=16926 **

Yes I know sorry, I will take it away soon just working on a new one :hangover:

well it just froze me up a couple times just to get into this
thread. I recommend you taking it down sooner please, cuz I’m
sure I’m not the only one.

thanks. :slight_smile: