# Simple script help (loop sort of)

**URL:** https://forum.kirupa.com/t/simple-script-help-loop-sort-of/284
**Category:** flash
**Created:** [July 12, 2002, 9:05am UTC](https://forum.kirupa.com/t/simple-script-help-loop-sort-of/284 "2002-07-12T09:05:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bodom78](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@Bodom78](https://forum.kirupa.com/u/Bodom78)
#### Post date: [July 12, 2002, 9:05am UTC](https://forum.kirupa.com/t/simple-script-help-loop-sort-of/284/1 "2002-07-12T09:05:41Z")

</div>

Hey all, Im still new to actionscript and I’m trying to understand it but with no luck.

What I want to do is set the alpha of a movieclip to rise and then lower at a set amount. I can do it so it set it at random but not the way I want it, eg clip starts at 20%alpah, and rised by 1 untill it at 50% and then reduces by 1 untill back to 20% over and over.

If you can be bothed explaining the script to me as well that would be great cos I want to understan why it works as well rather then just copy and pasting the script.

Thankyou.

(EDIT here what I tried, way off I know, but I’m still learning :))

second frame :

i = i+1;  
setProperty ("/grid", \_alpha, +i);  
result = getProperty("/grid", \_alpha);  
if (result = 50) {  
setProperty ("/grid", \_alpha, 50-i);  
}

third frame.

gotoAndPlay (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: [July 14, 2002, 5:13am UTC](https://forum.kirupa.com/t/simple-script-help-loop-sort-of/284/2 "2002-07-14T05:13:12Z")

</div>

i understand that _grid_ is the movieclip you want to mess with.  
Let’s start!

```auto
i = i+1;

```

The variable _i_ is increased by one

```auto
setProperty ("/grid", _alpha, +i);

```

the mc _grid_’s alpha is increased by “i”

```auto
result = getProperty("/grid", _alpha);

```

the _grid_’s alpha is indicated as “result”

```auto
if (result = 50) {
setProperty ("/grid", _alpha, 50-i); 
} 

```

If the result (the _grid_’s alpha) is 50 then  
the _grid_’s alpha will be deceased by 30 (50-20(i=30)).

```auto
gotoAndPlay (2);

```

## It tells it to go to frame to and play so it will make it a two-frame-loop. Notice that the alpha isn’t increased by one all the time but it it increased by the variable _i_ and the variable _i_ is increased by one.

BTW! Here’s alot easier and more handy way of doing this

```auto

i++
grid._alpha += i;
result = grid._alpha;
if (result == 50) {
grid._alpha = 50-i
}

```

Every line means the exact same thing as in the previous code 🙂

Hope that helped

---

<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: [July 15, 2002, 2:57am UTC](https://forum.kirupa.com/t/simple-script-help-loop-sort-of/284/3 "2002-07-15T02:57:46Z")

</div>

Thankyou so very much, this is just what I was after 🙂
