0
changing dynamic text colors ??
New Here
,
/t5/animate-discussions/changing-dynamic-text-colors/td-p/226658
Aug 20, 2007
Aug 20, 2007
Copy link to clipboard
Copied
In Flash 8, the dynamic text field instance name is
energyLevel, as is the variable name associated with it. This
field's text color was originally set to gold (outside of
ActionScript). In the code, I'm trying to change it to red (without
a condition at this point, just to see if it will work).
In the code prior to the init function:
energyLevel = 10;
I've tried Option 1: >>>>>>>>>>
newTextStyle = new TextFormat();
newTextStyle.color = "0xFF0000";
//
actor.onEnterFrame = function() {
energyLevel.setTextFormat(newTextStyle);
I've tried Option 2: >>>>>>>>>>>>>
actor.onEnterFrame = function() {
energyLevel.textColor = 0xFF0000;
And, I've tried Option 3: >>>>>>>>>>>>
actor.onEnterFrame = function() {
_root.energyLevel.textColor = 0xFF0000;
BUT, none work. This should be easy to do. Can anyone tell me what is wrong??
Thanks!
In the code prior to the init function:
energyLevel = 10;
I've tried Option 1: >>>>>>>>>>
newTextStyle = new TextFormat();
newTextStyle.color = "0xFF0000";
//
actor.onEnterFrame = function() {
energyLevel.setTextFormat(newTextStyle);
I've tried Option 2: >>>>>>>>>>>>>
actor.onEnterFrame = function() {
energyLevel.textColor = 0xFF0000;
And, I've tried Option 3: >>>>>>>>>>>>
actor.onEnterFrame = function() {
_root.energyLevel.textColor = 0xFF0000;
BUT, none work. This should be easy to do. Can anyone tell me what is wrong??
Thanks!
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guru
,
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226659#M334684
Aug 20, 2007
Aug 20, 2007
Copy link to clipboard
Copied
OK, first - do you have an instance name of 'energyLevel'
assigned to the textField? Second you do not need to create a
TextFormat just call:
energyLevel.textColor = 0xFF0000;
Also, you must have an MC with the instance name 'actor' that is instantiated on the timeline by the time you call the 'onEnterFrame' function.
I guessing you are missing the instance names.
energyLevel.textColor = 0xFF0000;
Also, you must have an MC with the instance name 'actor' that is instantiated on the timeline by the time you call the 'onEnterFrame' function.
I guessing you are missing the instance names.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Michael_1
AUTHOR
New Here
,
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226660#M334685
Aug 21, 2007
Aug 21, 2007
Copy link to clipboard
Copied
The suggestions you made had been done. After further
tinkering (and using only .textColor as you suggested), I found
that the problem was that the instance name needs to be different
from the variable associated with field in the properties window
(they had both been called energyLevel). Once I made one different,
this worked. Thanks for your assistance along the way.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226661#M334686
Aug 21, 2007
Aug 21, 2007
Copy link to clipboard
Copied
PS: Since About Flash 6, I think most of us do not use the
variables with text fields. It is much preferred to assign the
.text property and just leave the var blank.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guru
,
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226662#M334687
Aug 21, 2007
Aug 21, 2007
Copy link to clipboard
Copied
For sure Rothrock, and you're welcome .Michael.
@Rothrock - btw did you see my last post at that other Q about the tab shortcut, just wanted to make sure, that you know those comments weren't directed your way 🙂
@Rothrock - btw did you see my last post at that other Q about the tab shortcut, just wanted to make sure, that you know those comments weren't directed your way 🙂
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Michael_1
AUTHOR
New Here
,
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226663#M334688
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
I understand what you both said about using .text instead of
the variable, but what advantage does that give you? Just one less
variable?
Also, if a dynamic text field holds a number and you need to do math periodically on that number, isn't it just easier to have:
amountLeft = amountLeft - (AmountFraction*.332)
vs.
amountLeftField.text = amountLeft - (AmountFraction*.332)
in which case you'd have another variable anyway?
Also, if a dynamic text field holds a number and you need to do math periodically on that number, isn't it just easier to have:
amountLeft = amountLeft - (AmountFraction*.332)
vs.
amountLeftField.text = amountLeft - (AmountFraction*.332)
in which case you'd have another variable anyway?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guru
,
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226664#M334689
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
not exactly, read:
HERE
What if you are tracking a value that you don't want to display at the time, or want use it in other calculations. Also there are a few other ways to enter what you've got there, as in:
amountLeftField.text -= AmountFraction*.332;
amountLeftField.text *=.332;
amountLeftField.text /=1.332;
OR how about ...
a_txt.text -= f*.332;
Flash recognizes operations on a numerical value entry, performs the calc, and still displays as a String.
Additionally, if you use the underscore with an extention name for instance naming as in 'my_txt', Flash will recognize the extention and bring up a list of methods, properties and event handlers related to the data type when you type 'dot' after, if you have the 'code hints' preference turned on. Same with _mc, _btn, _ldr, _ti, _cb, ... etc. good for learning, and as you type the next few characters of the prop, the list will highlight the prop, and you can hit 'enter' to complete the rest, handy.
I'm not certain, but I believe that the TextField Var property has been eliminated entirely in AS3. (?)
What if you are tracking a value that you don't want to display at the time, or want use it in other calculations. Also there are a few other ways to enter what you've got there, as in:
amountLeftField.text -= AmountFraction*.332;
amountLeftField.text *=.332;
amountLeftField.text /=1.332;
OR how about ...
a_txt.text -= f*.332;
Flash recognizes operations on a numerical value entry, performs the calc, and still displays as a String.
Additionally, if you use the underscore with an extention name for instance naming as in 'my_txt', Flash will recognize the extention and bring up a list of methods, properties and event handlers related to the data type when you type 'dot' after, if you have the 'code hints' preference turned on. Same with _mc, _btn, _ldr, _ti, _cb, ... etc. good for learning, and as you type the next few characters of the prop, the list will highlight the prop, and you can hit 'enter' to complete the rest, handy.
I'm not certain, but I believe that the TextField Var property has been eliminated entirely in AS3. (?)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Michael_1
AUTHOR
New Here
,
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226665#M334690
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
OK - thanks for your additional insight!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guru
,
LATEST
/t5/animate-discussions/changing-dynamic-text-colors/m-p/226666#M334691
Aug 23, 2007
Aug 23, 2007
Copy link to clipboard
Copied
you're welcome 🙂
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

