Groups | Blog | Home
all groups > flash actionscript > october 2005 >

flash actionscript : Adding sound to buttons


GellyBean
10/16/2005 8:25:28 PM
Hi, guys...

I have this script for buttons:

btn.onPress = function() {
MC_Ball.play();
};
for (var i = 1; i<=5; i++) {
btn = _root["btn"+i];
btn.ivar = i;
prevMC = null;
btn.onPress = function() {
trace(this.ivar);
clearInterval(reverseI);
reverseI = setInterval(reverseF, 20, this.ivar);
};
}
for (var i = 1; i<=5; i++) {
btn = _root["btn"+i];
btn.ivar = i;
prevMC = null;
btn.onPress = function() {
trace(this.ivar);
MC_Ball.play();
clearInterval(reverseI);
reverseI = setInterval(reverseF, 20, this.ivar);
};
}
...etc


... I would like to add a sound to it... I've tried different ways like adding
the script below, before the script above... but its not working

btn.onRollover = function() {
MC_Sound.play();
};

Please help
GellyBean
10/17/2005 12:00:00 AM
Thank you Equan... I've tried that way too but still not workin'

Equan
10/17/2005 1:13:31 AM
if the sound you want to play is in the library.
you must first load the sound.
mc_sound = new Sound();
mc_sound.attachSound("idname");//name given as the linkage name.
btn.onRollOver = function(){
mc_sound.start(0, 0);
}
To assign your sound an idname, open the library and right-click on the sound.
click on "Linkage"
check the box that says "Export for ActionScript"
and take note of the idname it gives
Use this idname in the code above. Normally the idname will be the same name
as the file in the library.
AddThis Social Bookmark Button