arraysactionscript-3htmltext

Storing htmlText in Arrays


Im creating a simple program that will compare user input to a predetermined string (for memorization help). So far, after the user pushes space a code will run to break the user input text into individual characters (in an array) to test it against the original.

When the user pushes space and one of the letters is wrong, I want that letter to turn a different color. Is there any way to store htmlText in an array, or can anyone think of a way to make that letter turn the color?

Is there any way to write the program at all? Am I able to keep the text in a string and compare it (the spaces and punctuation need to be ignored)?


Solution

  • You can change color without htmlText.

    Use setTextFormat.

    example:

    var format:TextFormat = textField.getTextFormat(wrongLetterBeginIndex, wrongLetterEndIndex);
    format.color = 0xFF0000;
    textField.setTextFormat(format, wrongLetterBeginIndex, wrongLetterEndIndex);