ToolTip Sound in Adobe AIR/FLEX…

By | March 10, 2011

Sometimes we may need to have a sound when we hover over something, i.e when a tooltip appears.
Actually this can be done easily by adding an eventListener to the corresponding control.
Take a look at the example.
This line is the important line.

      myLabel.addEventListener(ToolTipEvent.TOOL_TIP_SHOW, myListener);

The function myListener gets called when we hover over the label thus producing the sound.
What you have to do is to just copy and paste the following code to your file.

       import mx.events.ToolTipEvent;
     import flash.media.Sound;

     [Embed(source="msgAlert.mp3")]

     private var myToolTipSound:Class;
     private var mySound:Sound;

     private function init():void {
        myLabel.addEventListener(ToolTipEvent.TOOL_TIP_SHOW, myListener);
        mySound = new myToolTipSound();
     }
      public function playSound():void {
        mySound.play();
     }
     private function myListener(event:ToolTipEvent):void {
        playSound();
     }
  ]]>
   

3 thoughts on “ToolTip Sound in Adobe AIR/FLEX…

Leave a Reply to James Cancel reply

Your email address will not be published. Required fields are marked *