Solved

Button sound on mouseover

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Closing FLash Privacy/Video Panel 2 858
Flex Builder 4.5 3 407
Show prior date in flex while date in database is different 7 459
Adobe Experience Manager 4 195
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…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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