• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • 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!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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