-
How to grab number at end of moviclip name as a var?
Hi
I have some buttons named bt1, bt2, bt3 etc
They have a common function for when each is clicked called buttonclicked.
Within the function buttonclicked, I'd like to grab the number off the end of each button name so that I can compare the number to a global variable I have called global.data.clicker
so...
if (number at end of event.target.name == global.data.clicker) {take action...
Is it possible, and if so, what code do I need to put in the first part of the if statement to make it work?
Thanks for your time and help.
Shaun
-
Senior Member
Use the substr method of the string class. So it would look something like this,
Actionscript Code:
event.currentTarget.name.substr(2); // 0 based index b = 0, t = 1, # = 2.
Try that.
Wile E. Coyote - "Clear as mud?"
-
Much appreciated Robb - works perfectly.
Thank you
Shaun
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|