# Assigning Handler Problem

**URL:** https://forum.kirupa.com/t/assigning-handler-problem/30171
**Category:** flash
**Created:** [September 4, 2003, 6:10pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171 "2003-09-04T18:10:15Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![grandsp5](https://avatars.discourse-cdn.com/v4/letter/g/6bbea6/32.png) [@grandsp5](https://forum.kirupa.com/u/grandsp5)
#### Post date: [September 4, 2003, 6:10pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/1 "2003-09-04T18:10:15Z")

</div>

I am trying to make an effct where a bunch of square fade in sequence (without using Voetsjoebas code btw, I’m practicing my own), but I have a problem with the handlers. I want to assign a handler to \_root[“square”+(i-1)] but it doesnt work if I do. Check out the comments in the code as well. Thanks.

NB - What you see now is the proper effect but I need to move the handler to a different place so that I can assign a different handler to \_root.

---

<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: [September 4, 2003, 7:19pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/2 "2003-09-04T19:19:36Z")

</div>

[AS]var k, i = 0;  
for (k=1; k\<=5; k++) {  
var mc = square0.duplicateMovieClip(“square”+k, k);  
mc.\_x = 100\*k;  
}  
MovieClip.prototype.fade = function() {  
var f;  
this.onEnterFrame = function() {  
this.\_alpha -= 5;  
if (!f && this.\_alpha\<=50) {  
this.\_parent[“square”+(++i)].fade();  
f = true;  
} else if (this.\_alpha\<=0) {  
delete this.onEnterFrame;  
}  
};  
};  
this[“square”+i].fade();  
stop();[/AS]

---

<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: [September 4, 2003, 8:48pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/3 "2003-09-04T20:48:49Z")

</div>

wonderful. Thanks kode!

---

<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: [September 4, 2003, 8:55pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/4 "2003-09-04T20:55:41Z")

</div>

What does this line do?  
[AS]  
this.\_parent[“square”+(++i)].fade();  
[/AS]

or rather how does it work

---

<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: [September 4, 2003, 10:05pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/5 "2003-09-04T22:05:19Z")

</div>

That’s kind of funny… you were using associative array referencing in your code, but you don’t know how it works.

Read this post by senocular: [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082#post85182](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082#post85182).

---

<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: [September 4, 2003, 10:08pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/6 "2003-09-04T22:08:07Z")

</div>

no no. I know associative array, what I dont understand is the ++i…i missed the dumb stuff. I looked it up and I see the operator but when I change it to i+1 it doesnt work. Isnt it the same?

---

<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: [September 4, 2003, 10:11pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/7 "2003-09-04T22:11:33Z")

</div>

Hi,

If you use ++i it increments and then uses the new value, if you use i++ or i+1 it increments after the use and in the case of i+1 it doesn’t store the value unless you have i=i+1

Hope this helps.

Liz

---

<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: [September 4, 2003, 10:12pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/8 "2003-09-04T22:12:45Z")

</div>

ok cool. So i have to use the prescript operator. Even parenthesis wont do it?

---

<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: [September 4, 2003, 10:15pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/9 "2003-09-04T22:15:36Z")

</div>

I’m not sure about the parenthesis… you could always give it a try and see 😉

Liz

---

<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: [September 4, 2003, 10:16pm UTC](https://forum.kirupa.com/t/assigning-handler-problem/30171/10 "2003-09-04T22:16:07Z")

</div>

i did…nothing

[edit] I got it. Thanks kode and lac [/edit]
