Search code examples
actionscript-3flashactionscript

How to Find Certain Areas of a Variable AS3


I do not have a project or anything, I just wanted to know if this was possible.

Let's say I have a variable that is a string,

var code:String="hello there"

is there any way possible I could keep that variable the same, while using it for only the first 10 letters (or any number of letters)?

For example, if I had 2 dynamic textboxes, could I assign one the first four letters of the variable, and the other one the last four letters of the variable?

Also, could I recognize a charCode and make that the endpoint? For example, could I recognize when a space occurs, and do all letters before that?

Thanks in advance.


Solution

  • var parts:Array = code.split(" ");
    

    Will do just like it says: split the string at all occurrences of the delimiter, which in this case is space.