View Full Version : Assigning Handler Problem
grandsp5
September 4th, 2003, 02:10 PM
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.
kode
September 4th, 2003, 03:19 PM
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();
grandsp5
September 4th, 2003, 04:48 PM
wonderful. Thanks kode!
grandsp5
September 4th, 2003, 04:55 PM
What does this line do?
this._parent["square"+(++i)].fade();
or rather how does it work
kode
September 4th, 2003, 06:05 PM
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.
grandsp5
September 4th, 2003, 06:08 PM
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?
lac
September 4th, 2003, 06:11 PM
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
grandsp5
September 4th, 2003, 06:12 PM
ok cool. So i have to use the prescript operator. Even parenthesis wont do it?
lac
September 4th, 2003, 06:15 PM
I'm not sure about the parenthesis... you could always give it a try and see ;)
Liz
grandsp5
September 4th, 2003, 06:16 PM
i did..nothing
I got it. Thanks kode and lac
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.