check if text “begin with” substring in Actionscript 3

actionscript-3, flash

Solution

There is an indexOf method: documentation.

It returns the first index of where the given string appears in the string that is searched. If this is not equal to `0`, it doesn't start with the string. You can make the following function yourself:

function startsWith(haystack:String, needle:String):boolean {
    return haystack.indexOf(needle) == 0;
}

Problem

How can I check if a text “begin with” substring in Actionscript 3 ?? Thanks a lot for help.

Original source