antonielloj
11-05-2004, 06:02 PM
hey all. i have a prototype function called changeIt that essentially alters any mc property at any rate (ill spare you that majority of the code because it works fine). but... i wanted to add a feature that allows the user to call a SECOND function when the first call is finished. in other words, if one wants to change an mc's _xscale from 50 to 200, then, once the mc is at _xscale=200, bring the _alpha down to 0, etc etc. hence the intended purpose of the last two parameters of the function (newObject and whenComplete). the setup of the function looks like this:
MovieClip.prototype.changeIt = function(prop:String, newVal:Number, rate:Number, newObject:Object, whenComplete:Function){
// ... lots of code that works
// ... when the function is completed
if (newObject) newObject[whenComplete];
// ... some more clean-up code that works
}
so, a call to this function might look like this:
mc1.changeIt("_y",150,2,_root.mc2,changeIt("_alpha",300,2));
The problem is that when the function is called, it is called TWICE immediately, and both calls are always invoked on mc1. im assuming this has to do with the fact that im passing a parameter of type:Function. however, is there any other way to call the function a second time when it has parameters that need to be passed into it?
im going crazy. please help! :)
cheers
j
MovieClip.prototype.changeIt = function(prop:String, newVal:Number, rate:Number, newObject:Object, whenComplete:Function){
// ... lots of code that works
// ... when the function is completed
if (newObject) newObject[whenComplete];
// ... some more clean-up code that works
}
so, a call to this function might look like this:
mc1.changeIt("_y",150,2,_root.mc2,changeIt("_alpha",300,2));
The problem is that when the function is called, it is called TWICE immediately, and both calls are always invoked on mc1. im assuming this has to do with the fact that im passing a parameter of type:Function. however, is there any other way to call the function a second time when it has parameters that need to be passed into it?
im going crazy. please help! :)
cheers
j