PDA

View Full Version : Passing Arguments to Functions


Captain Caveman
01-09-2009, 10:34 AM
Hi,

Can anyone tell me how to send an argument to a function (actionscript 3) and then use the argument within a path?

For example, if I was trying to tell flash to play a curtain closing animation and needed to send a variable telling it which movieclip to play - this is how I'm trying to do it:

function closeCurtains(curtain) {

this.curtain.play();
}

closeCurtains(living_room);

This is the error I get:
TypeError: Error #1010: A term is undefined and has no properties.
at Untitled_fla::MainTimeline/closeCurtains()
at Untitled_fla::MainTimeline/frame1()

Can anyone see where I'm going wrong?

Flash Gordon
01-09-2009, 10:50 AM
"this" changes the scope of the variable to the class I would think. just use curtain.play(); and it should work.

Captain Caveman
01-09-2009, 11:15 AM
Thanks, you're right, that's done the trick!