PDA

View Full Version : passing mc name as as a parameter



leadtrum
October 15th, 2004, 09:35 AM
I'm trying to pass an mc instance as a paramter of a function. is this possible because I keep getting errors.


function moveCircle(sIncrement:Number, sMovie:String):Void {
sMovie._x +=sIncrement;
}

sMovie is the instance i'm trying to reference


on(release){
moveCircle(10, "mc_Circle");
}

this is the button code

I'm trying to do this to cut down on redundant functions I've used in the past for simple as movements and controls. Is this possible?

tizzle
October 15th, 2004, 12:12 PM
Try using the correct name for your variable. It's a MovieClip not a String. Your code thus becomes:


function moveCircle(sIncrement:Number, sMovie:MovieClip):Void {
sMovie._x +=sIncrement;
}

so yes it's possible. the above should work fine...

leadtrum
October 15th, 2004, 12:25 PM
d'oh...thanks, i'm retarded

also the " marks need to be removed from the mc_name