Other Software > Developer's Corner
[ActionScript 3/Adobe Flash] Play a sound when user clicks button?
RedPillow:
I found something like this:
--- Code: ActionScript ---var snd:MySound1= new MySound1(); soundbutton_MC.addEventListener (MouseEvent.CLICK, soundbutton_Handler); function soundbutton_Handler (e:MouseEvent):void {snd.play(); }
I have the sound-effect in my Adobe Flash's library ... where should I put it and how to make the script know to play that one?
Deozaan:
I don't know for sure, but it looks like the sound file might be defined in the MySound1 class.
RedPillow:
You might be right ... someone said this:
sound works just as movieclips, create a sound in the .fla, use the linkage dialog in teh library and set Class to: "MySound1"
then use it with:
var snd:MySound1= new MySound1();
snd.play();
should work..
--- End quote ---
But since Im new with flash I have no idea how to "create a sound in the .fla, use the linkage dialog in teh library and set Class to: "MySound1"".
(Incase it's important ... Im making a basic starting-sequence for a flash-game/animation like "Game by: blahahah" and there's a button which links to my twitter but I want it to make *click* -sound when clicked)
Deozaan:
It's been a few years since I used Flash, but I think you can import a sound file to your library from the File -> Import menu. As for linkage, right click the file in your library and look for a "linkage" option. It may be in the "Properties" menu.
For more specific help, I suggest you check the help file since I'm sure it would cover importing sound files and library linkage.
RedPillow:
Aha!
It was hidden under Advanced > Something > Something :P
[ActionScript 3/Adobe Flash] Play a sound when user clicks button?
Got it to work just right - Thanks so much for help!
- RedPillow
Navigation
[0] Message Index
[#] Next page
Go to full version