[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

MouseOver to change text from default to red

I am brand new to Flash and have both Flash CS4 and Flash 8.

I have a static menu bar (words only) and want to create a MouseOver event which turns the text red.

It seems I have a bunch of steps just to do this, but I am thinking I am just missing an obvious point. I want the text to remain as TEXT so I can edit later and have this MouseOver event.

Can you help me see the light, here?
Thank you!
John Darby
John Darby
1 Solution
OK let's simplify this by showing you all in code how you change the text's colour.

This is timeline scripting to simplify the code.

I added comments for each line of code.

 var txt:TextField = new TextField(); // create a new textfield
            txt.text = "HELLO"; // set the textfield's text
txt.autoSize =TextFieldAutoSize.LEFT // makes the textfield resize but itself
            addChild(txt); // show on stage
            txt.addEventListener(MouseEvent.MOUSE_OVER, toRed); // on roll over change to red
txt.addEventListener(MouseEvent.MOUSE_OUT, toBlack); // on roll over change to black

function toRed(e:MouseEvent):void { // function to change to red
txt.textColor = 0xFF0000;

function toBlack(e:MouseEvent):void { // function to change to black
txt.textColor = 0x000000;
John DarbyPMAuthor Commented:
Very cool! I will be able to integrate this into the project...Thank you!

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now