?
Solved

Button sound on mouseover

Posted on 2012-12-27
4
Medium Priority
?
495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 29

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 1000 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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