Skip navigation
Currently Being Moderated

Basic AS3 Coding help needed

Sep 19, 2012 5:47 PM

I just added my first code to make a text field appear when a user mouse over it. The code below works perfectly.

 

My question: What code do I need to add for the same text field to disappear when the user mouse out?

 

Thanks for your help.

 

/*Here is my code that works well for mouse_over (now I just need mouse_out)*/

 

FLags.addEventListener(MouseEvent.MOUSE_OVER, fl_ClickToPosition);

 

var fl_TF:TextField;

var fl_TextToDisplay:String = "UK or USA english Spelling.";

 

function fl_ClickToPosition(event:MouseEvent):void

{

    fl_TF = new TextField();

    fl_TF.autoSize = TextFieldAutoSize.LEFT;

    fl_TF.background = true;

    fl_TF.border = true;

    fl_TF.x = FLags.x;

    fl_TF.y = FLags.y + FLags.height + 5;

    fl_TF.text = fl_TextToDisplay;

    addChild(fl_TF);

}

 
Replies
  • Currently Being Moderated
    Sep 19, 2012 6:53 PM   in reply to Charine -FB buggoop

    You'll need to create a listener for a MOUSE_OUT event. 

     

    What you might want to do with what you have already is to instantiate the textfield (fl_TF = new TextField();) outside of the function so that you don't end up creating a new one every time you rollover.  Then you could reuse the same textfield over and over by having the addChild(fl_TF) in the rollover function and removeChild(fl_TF) in the rollout function

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2012 3:57 PM   in reply to Charine -FB buggoop

    You're welcome.

     

    Button symbols  (SimpleButton objects) can serve a purpose and can save you some work when you want a simple appear/disappear hovering effect. 

     

    The only question is whether or not you can do it using code... it's a good thing to know how to do, so you oughta give it a try at some point.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points