# Scripted loops

**URL:** <https://forum.kirupa.com/t/scripted-loops/15526>\
**Category:** Uncategorized\
**Created:** [March 15, 2003, 5:00am UTC](https://forum.kirupa.com/t/scripted-loops/15526 "2003-03-15T05:00:13Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 19, 2003, 10:36pm UTC](https://forum.kirupa.com/t/scripted-loops/15526/21 "2003-03-19T22:36:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 1:01am UTC](https://forum.kirupa.com/t/scripted-loops/15526/22 "2003-03-20T01:01:11Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 2:26am UTC](https://forum.kirupa.com/t/scripted-loops/15526/23 "2003-03-20T02:26:50Z")

</div>

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](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=16926)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 2:29am UTC](https://forum.kirupa.com/t/scripted-loops/15526/24 "2003-03-20T02:29:00Z")

</div>

Oops, the attachment MIGHT help 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 9:31am UTC](https://forum.kirupa.com/t/scripted-loops/15526/25 "2003-03-20T09:31:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 3:53pm UTC](https://forum.kirupa.com/t/scripted-loops/15526/26 "2003-03-20T15:53:00Z")

</div>

Like this?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 4:36pm UTC](https://forum.kirupa.com/t/scripted-loops/15526/27 "2003-03-20T16:36:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 4:49pm UTC](https://forum.kirupa.com/t/scripted-loops/15526/28 "2003-03-20T16:49:11Z")

</div>

Alright, how about this then.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 21, 2003, 3:48am UTC](https://forum.kirupa.com/t/scripted-loops/15526/29 "2003-03-21T03:48:02Z")

</div>

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:

```auto

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 21, 2003, 5:58pm UTC](https://forum.kirupa.com/t/scripted-loops/15526/30 "2003-03-21T17:58:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 21, 2003, 8:59pm UTC](https://forum.kirupa.com/t/scripted-loops/15526/31 "2003-03-21T20:59:57Z")

</div>

> \*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](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=16926) \*\*

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 22, 2003, 2:42am UTC](https://forum.kirupa.com/t/scripted-loops/15526/32 "2003-03-22T02:42:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 22, 2003, 3:34am UTC](https://forum.kirupa.com/t/scripted-loops/15526/33 "2003-03-22T03:34:25Z")

</div>

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. 🙂

[Previous page](https://forum.kirupa.com/t/scripted-loops/15526.md?page=1)
