View Full Version : change colour of TEXT in dynamic text field?
gav.cooper
03-08-2008, 05:39 AM
hi,
I am wanting to change the colour of the text in the dynamic text field "myText" ... want to change it to RED (#FF0000) when the count down fucntion turns the dispalyed text to 1...
function countDown(event:TimerEvent):void {
if (currentFrame == 5) {
myText.text = String(250 - timer.currentCount);
if ((250 - timer.currentCount) ==1) {
myText.TextColorType ==#FF0000();
}
HOW?
error - "1093: Syntax error."
GordonG
03-08-2008, 02:05 PM
gav,
this has several syntactical problems:
myText.TextColorType ==#FF0000();
4. TextColorType 1. == 3. # 2. ()
1. "==" is reserved for testing equality, not assigning a value. Use one "=" in an assignment statement.
2. you are assigning a color, in your case a numeric literal ( that IS what you mean to do.) it is not a function or method - those end in parens "()" - a literal may not end in "()"
3. a numeric literal can be expressed in several ways, but never started with a "#" If you mean to write a hex literal, it needs to start with "0x" followed by the hexadecimal value of the color (what you have written in your code.)
4. there is no text field property "TextColorType" - you cannot set the color of text in a text field using that non existent property. To set the color of a text field, you'll need to read the documentation (Flash Help) about the TextFormat class. It's a separate object you'll have to create and apply to the text field.
I could give you the answer here, but you're likely to get lost on the next step. In short, you have to do some reading. Look in the Flash Help files under TextField and TextFomat - both of those entries have a lot of examples that will show you exactly what you need to know, and you will learned it better than if someone merely gives you the answer.
Cheers!
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.