Solved

Button sound on mouseover

Posted on 2012-12-27
4
464 Views
Last Modified: 2012-12-28
Greetings.

How do I add a 'click' sound on mouseover that will apply to all buttons in my flex project? Looking forward to your responses.

Thanks
0
Comment
Question by:zerog
  • 2
4 Comments
 
LVL 28

Expert Comment

by:chilternPC
ID: 38723496
Im not a flex expert but the following forum seems to answer your question.
http://www.actionscript.org/forums/showthread.php3?t=97253
0
 
LVL 37

Accepted Solution

by:
CyanBlue earned 250 total points
ID: 38723832
The above code is done in AS2 and it won't work in Flex environment.

You can do something like this.

CyanBlue
<fx:Script>
	<![CDATA[
	
		private function onRollOver(e:MouseEvent):void
		{
			var sound:Sound = new Sound(new URLRequest("path/to/sound.mp3"));
			sound.play();
		}
		
	]]>
</fx:Script>

<s:Button width="100" height="50" label="ROLL OVER ME" mouseOver="onRollOver(event)" />

Open in new window

0
 

Author Comment

by:zerog
ID: 38724275
CyanBlue I've tried your response but get the following error, maybe I'm implementing it incorrectly.

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
      at outreach/onRollOver()[C:\outreach\src\outreach.mxml:35]
      at outreach/___outreach_Button19_mouseOver()[C:\outreach\src\outreach.mxml:290]


This is the code for one of my many buttons in the interface

<s:Button includeIn="State1" width="158" height="170"
                    label="Learn the link"
                    color="#FFFFFF" fontSize="22" horizontalCenter="310" skinClass="skins.TransBtn2"
                    verticalCenter="-2"
                    click="currentState='interface1'"/>
0
 

Author Comment

by:zerog
ID: 38727747
Got it working. My path to the sound file was incorrect. Thank you for a really simple solution.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now