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)*/
var fl_TextToDisplay:String = "UK or USA english Spelling.";
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;
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
I realised that I could use the button function with the text added to the over state with no extra code. It works fine that way.
Is this a good practice, or should I rather use code to do this?
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.