0
for(var temp:int = 0;temp<recipeNum;temp++)
{
    if ((temp == 1) || (temp == 2) || (temp == 6) || (temp == 9))   
    {
        textRecipe.textColor = 0x0000FF;
    }
    else
    {
        textRecipe.textColor = 0x000000;
    }

    textRecipe.text += "\n" + recipe[temp];
    addChild(textRecipe);                   
}

The problem with this code all the text on screen is black. I want temp 1,2,6,9 to be blue, any solutions.

0

1 Answer 1

3

If I'm not wrong you're using only one TextField named textRecipe.

Note that, even if you add it recipeNum times to the stage, it's always the same object.

Assigning textColor property, it modifies the color of the entire text, so the last color assigned (probably black) will be the color of the entire text.

Either use more than one TextField or use a TextFormat to assign color to a part of the text:

var myFormat = new TextFormat();
myFormat.color = 0x0000FF;

textRecipe.setTextFormat(myFormat, 5, 8);  //sets color blue to chars from 5 to 8

Let me know if you need more help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.