Skip navigation
Lo_onger
Currently Being Moderated

How to add a title to button in flash?

Apr 12, 2012 3:12 AM

Tags: #button #title

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.

 
Replies
  • Currently Being Moderated
    Apr 12, 2012 3:35 AM   in reply to Lo_onger

    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 = "";
     
    }
     
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 3:51 AM   in reply to Lo_onger

    yeah I just gave you a AS3 version of what you gave me.

     

    the error means you have no object on the stage called text

     

    when you say you want to have a title, what you are using to present the title? a textfield? what is it's name?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 4:01 AM   in reply to Lo_onger

    I am trying to find out what you mean by title

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 4:05 AM   in reply to Lo_onger

    ahh, you want a tooltip?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 4:13 AM   in reply to Lo_onger

    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

     
    |
    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