Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoking methods from variable names

Status
Not open for further replies.

Terwin

Programmer
May 23, 2002
51
US
I'm a bit disappointed in myself that I couldn't come up with the answer to this one.. thanks in advance for your answers.

Here's my actionscript for a button - each frame has a corresponding movie clip called "showmeclip#," with the # corresponding to the frame in the main timeline.

on (release) {
var currFrame = _level0._currentframe;
var clipName = "showmeclip" + currFrame;
clipName.gotoAndPlay(2);
}

Flash does not seem to want to invoke the gotoAndPlay(2) function based on clipName. Thoughts?

Thanks,
Terwin
 
try this way but be carreful with the "showmeclip" location:

on (release) {
var currFrame = _level0._currentframe;
var clipName = "showmeclip" + currFrame;
[clipName]gotoAndPlay(2);
}

for all sort of thing that u want to do whit variables for exemple properties os methods, u remove the . after the variable name and put it in []
 
Just what I was looking for - thanks a million.

T
 
This is the correct way:

on (release) {
_root["showmeclip"+_root._currentframe].gotoAndPlay(2);
} Regards
David Byng
bd_logo.gif

davidbyng@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top