[AS1/2] passing an object as a variable in a function

I have a movieClip prototype that calls another function once it has finished.
The other function could be one of many.
I want to be able to pass the variables of the second function to the first function:

MovieClip.prototype.func1=function(varA,varB,func2name,func2args){
// do something
// once done call second function:
this[func2Name](func2args.join(','));
};

// called using:

myMC.func1(varA,varB,"func2Name",{func2Arg1:value, func2Arg2:value})

Any idea how this should be written?
At the moment only the first variable of func2 is populated…

Thanks for helpin me out on this 1 :slight_smile:

Ed

Ah, for that you use function.apply:


  MovieClip.prototype.someFunc = function(varA,varB,finishFunc,finishObj,finishParams){
  // do some stuff...
  finishFunc.apply(finishObj,finishParams);
  }
  MovieClip.prototype.funcToCall = function(msg){
  trace(msg);
  }
  this.someFunc(a,b,MovieClip.prototype.funcToCall,_root,["hello there"]);
  

That will execute MovieClip.prototype.funcToCall ‘on’ _root, so basically _root.funcToCall (funcToCall was declared in the MovieClip prototype).

*For some reason it keeps inserting that space in finishParams, remove it.

Thanx Voetsjoeba - you are a star - been tearin my hair out for days now - gonna need some regain!
Thanks again,
Ed

You’re welcome, m00g :slight_smile: