1

I am learning AS3 (coming from a PHP background) and I have hit a wall.

Basically I have this code:

var activeNotesNames:Array; activeNotesNames = new Array; activeNotesNames.push("ABC"); 

and doing a

trace(activeNotesNames[0]) 

gives me "ABC" but if I just want the first character (in this case that would be "A") how do I get that?

I tried trace(activeNotesNames[0][0] but that gives me an error.

1
  • 1
    The problem with [0][0] is that the String "ABC" is not an array. As Pan pointed out, you need to use a method of the String class to access individual characters. That syntax would work if instead of having a String you had another array in there. Commented Jun 25, 2013 at 3:00

1 Answer 1

3
activeNotesNames[0].charAt(0); 

Or you can try substr

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! Can you tell me which is an easy place to look up methods like this? Compared to php.net finding this stuff for AS3 is quite hard... but I think I am looking in the wrong places. (I have to wait 9 mins to accept your answer)
You can find the api in adobe livedoc, it helps a lot when you are not familiar with the api. help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.