Hi,
I have a button in flash and a action layer with the following script:
button1.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://mortimerhall.99k.org/homepage.htm"),"_self");
}
Now I would like to have a title when user move mouse over a button eg "Click To Enter".
I tried this code in a new layer but it doesn’t work:
on (rollOver) {
text = "hello";
}
on (rollOut) {
text = "";
}
I would be grateful if you could help with it.
The button has of course the "Instance Name".
Thanks ![]()
PS My first post, sorry for wrong place or any mistakes
I have a cs5.5 Pro.
this is AS2 code
on (rollOver) {
text = "hello";
}
on (rollOut) {
text = "";
}
the AS3 version would be something like
button.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
button.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
function rollOverHandler(e:MouseEvent):void
{
text = "hello!";
}
function rollOutHandler(e:MouseEvent):void
{
text = "";
}
I have add new layer on the top and copy that code. I have also change the button to button1.
Doesn't work
there are following errors:
| Scene 1, Layer 'Layer 8', Frame 1, Line 8 | 1120: Access of undefined property text. |
| Scene 1, Layer 'Layer 8', Frame 1, Line 18 | 1120: Access of undefined property text. |
I think you have misunderstand me.
I have found that code on the internet and apparently it is not what I'm looking for.
I just want a text to appear when user move his mouse over a button.
"when you say you want to have a title, what you are using to present the title? a textfield? what is it's name?"
can you explain a little bit more?
I don't have any title yet.
it's fine being new to flash, but when you don't explain what you are trying to achieve very clearly and then use terms like title when you mean tooltip cna be very confusing for those trying to help.
there are lots of examples of how to do tooltips
http://blog.hy-brid.com/flash/25/simple-as3-tooltip/
http://abrahamyan.com/2009/02/05/tooltip-in-as3/
you could try any of these and adapt them to you needs but if you are new i guess you will find this quite confusing.
a simple method (I assume you are using Flash Professsional CSX).
1) add a TextField to the stage, give it a name (e.g. titleTextField)
2) give the TextField some text (e.g. click me!)
3) set the visibilty of the TextField to false (e.g. titleTextField.visible = false)
4) in the rollover function i gave you earlier set the visibilty of the TextField to true
5) in the rollout function i gave you earlier set the visibilty of the TextField to false
Thanks! Your method is working fine. It is enough for my needs.
For any one that may want to see it:
button1.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
button1.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
function rollOverHandler(e:MouseEvent):void
{
text2.visible = true;
}
function rollOutHandler(e:MouseEvent):void
{
text2.visible = false;
}
it's fine being new to flash, but when you don't explain what you are trying to achieve very clearly and then use terms like title when you mean tooltip cna be very confusing for those trying to help.
Sorry, my bad ![]()
Thanks again!
North America
Europe, Middle East and Africa
Asia Pacific