PDA

View Full Version : trouble with charAt


philspeakman
03-25-2003, 12:31 PM
i am using this line in a function to create 17 buttons named accordingly_root.createEmptyMovieClip("button"+i, 100+i);
this is fine, but i need to acces the buttons number, doing trace(this) on a press of the button but i need just the number and can't get charAt to work
buttonName = this;
letterplace=buttonName.charAt(1);
trace(letterplace)
am i being stoopid...
Phil

CyanBlue
03-25-2003, 01:42 PM
Howdy...

You cannot use charAt() function because it will return 1 character at the specific position... and your number will be either 1 digit or 2 digits...

I have tried this and it goes like this...buttonName = "button17";
letterplace=buttonName.substr(6);
trace(letterplace);

philspeakman
03-25-2003, 02:11 PM
cheers.. but i can't hardcode the button name, as it's all part of a function that loops and creates a mc on 17 loops, the buttons are named ["button"+1]
any more thoughts?

philspeakman
03-25-2003, 02:18 PM
oh imay have got the wrong end of the stick there, d'oh

CyanBlue
03-25-2003, 02:26 PM
Did you get it working??? I think it should be this...buttonName = this._name;

philspeakman
03-25-2003, 02:32 PM
i think i love you...

CyanBlue
03-25-2003, 02:39 PM
Um... I'll have to ask my wife about that... ;)

bluegel
03-25-2003, 02:40 PM
is there something you haven't told your wife CyanBlue?

CyanBlue
03-25-2003, 02:42 PM
Um... Something like... I have lady buddy??? :D

I can't cuz she'd going to kill be for that...
You're welcome to do that if you don't want to see me anymore... :(

philspeakman
03-25-2003, 03:25 PM
worry ye not gentlemen, i'm totally hetro ("Goatboy likes young girls..") it's the love of a man who just been taught that you can use this._name and not this.inatanceName as i was trying

bluegel
03-25-2003, 07:29 PM
its good that you got things sorted phil!

did he just say gentlemen, CyanBlue?? where on earth did he get the impression that we are both male?? think I'll have to change my avatar to a lady!!

CyanBlue
03-26-2003, 10:07 AM
Um... Not sure where he'd got that idea... ;)

As for the avatar... Well... somethiing should be done since I see your cat and Mort's cat fighting all the time... What about changing it to a dog??? :D

Oh, philspeakman...
I don't mean to embrass you or anything, but I didn't tell you this._name in the beginning on purpose hoping you find it by yourself... That way the information usually gets kept longer... ;)
Hm... Who says I love hetero boy??? http://www.suburbia.com.au/~morpheus/smilies/axechase.gif
I love girls... Don't I, bluegel??? http://www.suburbia.com.au/~morpheus/smilies/hippy.gif