all groups > flash (macromedia) > april 2007 >
You're in the

flash (macromedia)

group:

How to change static text color?


Re: How to change static text color? David Stiller
4/6/2007 4:47:22 PM
flash (macromedia):
worldly1,

[quoted text, click to view]

Static text fields can't be styled via ActionScript, so you'll either
have to apply color changes to the movie clip containing that text field, or
convert the text to dynamic and take it from there.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

How to change static text color? worldly1
4/6/2007 8:45:18 PM
Hello All,

I have an instance of a static text movie clip and a separate button instance.

What I want to happen is when the button is rolled over it changes the color
of the static text. I know how to do the rollover event and address the movie
clip in action script, but I need to know how to change the color. I've played
with TextFormat.color and setProperty but haven't got it to work.

I know this is basic stuff, and I've tried to find the answer on my own, but
I'm at the point that I've got to ask.

Thanks, Scott
Re: How to change static text color? David Stiller
4/6/2007 9:27:45 PM
Scott,

[quoted text, click to view]

You may have seen some of this in your experimentation with the
TextFormat class. Basically, you instantiate a TextFormat object ...

var fmt:TextFormat = new TextFormat();

Then you set the color property of that instance.

fmt.color = 0xFF0000;

In this case, the 0x is like the # in HTML hexadecimal colors: it lets
Flash know, "Hey, the following characters are a hexadecimal number," and
FF0000 is red.

Finally, you invoke the TextField.setTextFormat() method on your
TextField instance. This is why the text field has to be dynamic (or
input), rather than just static text. Non-static text is an instance of the
TextField class, which means you can give that instance an instance name --
which you can do by selecting the text field and directing your attention to
the Property inspector -- then using the TextFormt instance as the parameter
of the described method. e.g., if your text field's instance name is myText
....

myText.setTextFormat(fmt);

All together, now ...

var fmt:TextFormat = new TextFormat();
fmt.color = 0xFF0000;
myText.setTextFormat(fmt);

In ActionScript, classes define objects, and objects are what you
manipulate with ActionScript. Classes define properties (characteristics),
methods (things the object can do), and events (things the object can react
to), and the ActionScript 2.0 Language Reference is strongly organized
around classes.

[quoted text, click to view]

Six of one, half a dozen of the other. Static text embeds font outlines
automatically, so you can rotate static text (for example) and still see the
text. Dynamic text won't do that unless you ask it to (see the Embed button
on the Property inspector, of the TextField class in the reference).

[quoted text, click to view]

Convert it to a movie clip, and you have access to all the feature of
the MovieClip class. Convert it to a graphic symbol, and there is no
corresponding Graphic class (just as there is not StaticText class). Just
one of those things. ;)


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Re: How to change static text color? worldly1
4/6/2007 11:16:07 PM
Thanks David,

3 questions:

1) If I change it to dynamic, how do I go about changing the color?

2) is there a downside to using dynamic text rather than static?

3) what if I convert the text to a graphic instead? Any reason not to go that
route?

Thanks, Scott
AddThis Social Bookmark Button