function01(mcName,{prop1:'asdf',prop2:'asdf');
Like with tweener, thanks in advance.
How can I get a function to work like this:
function01(mcName,{prop1:'asdf',prop2:'asdf'});
Like with tweener, thanks in advance.
Declare you function like this: (then call it as you have above)
function function01(mc:MovieClip, properties: Object)
{
trace (mc); // result = "[object MovieClip]"
trace (properties.prop1); // result "asdf"
trace (properties.prop2); // result "asdf"
}
BTW – I don’t accept thanks in advance .. I want more thanks now 
function changeMyMC(movieClip, newWidth, newAlpha) {
eval(movieClip)._width = newWidth;
eval(movieClip)._alpha = newAlpha;
}
Of course, if you wanted a tween, the function would have to occur gradually over time. One easy way to accomplish this, would be to use an onEnterFrame, like so:
function tweenMyAlpha(movieClip, incrementAlpha, numFrames) {
eval(movieClip).framesLeft = numFrames;
eval(movieClip).onEnterFrame = function() {
if(this.framesLeft > 0) {
this._alpha += incrementAlpha;
}else{
this.onEnterFrame = null;
}
}
If you use an onEnterFrame, just remember that the function won’t trigger during the same frame that you made the function (only the frames after it).
How can I get a function to work like this:function01(mcName,{prop1:'asdf',prop2:'asdf'});Like with tweener, thanks in advance.Declare you function like this: (then call it as you have above)
function function01(mc:MovieClip, properties: Object) { trace (mc); // result = "[object MovieClip]" trace (properties.prop1); // result "asdf" trace (properties.prop2); // result "asdf" }BTW – I don’t accept thanks in advance .. I want more thanks now
Oh, you just want to use an object in the parameters? Yeah what he said then.
Well that’s a fair bit of work, but the basic idea would be lines of code like this:
I could be wrong but I think x360 is asking how to use an object to pass a variable and unordered set of parameters to a function (like Tweener) not to reproduce the functionality of Tweener.
BTW when I have a lot of properties I want to pass to such a function, for readability, instead of creating the object anonymously in the function call (using curly braces) I will instantiate and initialize an object outside the parameter list, then jsut pass a reference to it in the function call. In your example case that would look like:
var params: Object = new Object(); params.prop1 = "asdf"; params.prop2 = "asdf"; ... etc.
then call the function like this :
function01( mcName, params);
The function body does not need to change to handle this.
You can, of course, use this method with Tweener, etc.
