• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamic Text and changing Text in AS3

Guest
Sep 09, 2010 Sep 09, 2010

Copy link to clipboard

Copied

I have a Dynamic Text box in my Library.  I drag it to my main stage and give it a name..it is now a movieclip. The name is 'mcAdmin'.  I added an event listener for MOUSE_OVER.  I want the text to change color, but for now I'm just trying to change the text; however, it's not displaying the change in text I want.  I do a trace, and the change is in there on the output window, but it is not displayed as such.  How can I :

1) use AS3 to change the font color of the text

2) use AS3 to change the text and have it display?

function onMouseOver_txtAdmin(e:MouseEvent):void
{
Mouse.cursor="button";

//Current mcAdmin text is 'Administration'

//I want to change the color of Administartion on Mouse_Over

//but to test if I can get to anything, I'm just trying to change the text.


mcAdmin.text="Hello";
trace(mcAdmin.text);


mcPPMB.alpha=.5;
mcASB.alpha=.5;
mcISO.alpha=.5;
mcEA.alpha=.5;
mcAdmin.alpha=1;

mcAdmin.scaleX=1.25;
mcAdmin.scaleY=1.25;
}

Thanks.

TOPICS
ActionScript , Code

Views

67.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Sep 09, 2010 Sep 09, 2010

1st

give the textfield a name, if it hasn't already (sounds like you put it in a movieclip).

to change the text set the text property of your text field

like this

myTextField_txt.text = "here is the text";

or if it is inside a movieclip

myClip_mc.myTextField_txt.text = "here is the text";


To change the color you would need to put a TextFormat on it. To keep the same fontsize, font etc. you could first get the TextFormat from your existing Textfield, change the color of the TextFormat and set it on the

...

Votes

Translate

Translate
Contributor ,
Sep 09, 2010 Sep 09, 2010

Copy link to clipboard

Copied

1st

give the textfield a name, if it hasn't already (sounds like you put it in a movieclip).

to change the text set the text property of your text field

like this

myTextField_txt.text = "here is the text";

or if it is inside a movieclip

myClip_mc.myTextField_txt.text = "here is the text";


To change the color you would need to put a TextFormat on it. To keep the same fontsize, font etc. you could first get the TextFormat from your existing Textfield, change the color of the TextFormat and set it on the TextField.

// get the Textformat of the first character

            var TF:TextFormat = myTextField.getTextFormat(0,1)

// set the font color
            TF.color = 0xff0000;

// put it on the whole text
            myTextField.setTextFormat(TF)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 09, 2010 Sep 09, 2010

Copy link to clipboard

Copied

LATEST

Dealing with the TextArea component, I was use to something like myTextArea.textField.text="Hello"...but I remembered to get to the library, I had to do as you suggested, mcStageText.txtLibraryText.text="Hello"  worked great.

I didn't use your Format way, I was able to do this: mcStageText.txtLibraryText.textColor=0xFFFFFF;   So far, works just like I wanted.

Thanks !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines