MouseOver to change text from default to red

Posted on 2009-12-24
Last Modified: 2013-11-11
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!
Question by:johndarby
    LVL 14

    Accepted 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;
    LVL 1

    Author Comment

    Very cool! I will be able to integrate this into the project...Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now