Solved

Button sound on mouseover

Posted on 2012-12-27
4
480 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 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

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

Question has a verified solution.

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

Suggested Solutions

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…
Changing a few Outlook Options can help keep you organized!
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

738 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