SetInterval function calls, this question

I am trying to create the effect of falling leaves and as part of this effect, I am writing a function called fall which takes 2 parameters, speed and angle. The function “fall” is called using SetInterval from the movie clip itself every 1 second. I have a problem though that I cant get around. Here is the code for the function fall

[AS]
MovieClip.prototype.fall = function(speed, angle) {
this._x += Math.sin(angle)*3;
this._y += speed;
};
[/AS]

and this is the code that calls it from the movie clip
[AS]
onClipEvent (load) {
var speed = (.5+Math.random())*4;
var angle = Math.random()*50;
interval = 1000+Math.random()*1000;
setInterval(fall,interval , speed, angle);
}
[/AS]

my problem is I can’t figure out to to get the “this._y” statement and the “this._x” statement to reference the movie clip. When I call the funciton fall, this becomes undefined and does not reference anything. I tied this

[AS]
setInterval(this.fall,interval , speed, angle);
[/AS]

but that didn’t work very well. The only way around it I can think of is to pass the instance name of the movie clip I am calling it from as a parameter and use that instead of “this”. Basically, my question is how do I use 1 function that I wrote, called through setInterval, to have command over numerous different movie clips. I want to use 1 function to control all the leaves. If you need a better explanation, I will try. Thanks a bunch

One question, maybe kax can answer…
can you call set interval for a prototype? :eye:

You can, claudio. :wink:
[AS]setInterval(this, “fall”, interval, speed, angle);[/AS]

Thx for the info kax :wink:

Anytime. :stuck_out_tongue:

gotcha. thanks a bunch. and claudio, i think he is kode now. kax has been deprecated

No problem, grandsp5. :wink:

And yeah, kax has been deprecated. I don’t mind if you guys still call me kax, though. :stuck_out_tongue:

*Originally posted by kode *
And yeah, kax has been deprecated.
I didnt know you were a scripting language Kax :stuck_out_tongue: :stuck_out_tongue:
Guess thats why you are such good coder
:beam:

Yup! I’m always up-to-date. :stuck_out_tongue:

And thanks for the compliment. :blush: