Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

saving time with actionscript

Status
Not open for further replies.

z35

Programmer
Dec 21, 2001
206
US
hello,
I am adding the same sound to many many rollover buttons.
is there a way to add sound to one button and then tell flash to repeat this on all the other buttons?

if i want to change the sound, i feel ridiculous editing each button.

 
Only if all the buttons were created from the original..

Create one button with the sound and all, except the text..

Now create duplicates of the original button each with a different name, or just leave it as flash calls it "copy", "copy1", "copy2" etc...Then go back and just ad your text..

Now if all your buttons were created with different symbols and instances, then no you can not automate adding sounds to different buttons..

Have fun
logo.gif


carlsatterwhite@orlandomediasolutions.com
 
If you're using F5 or MX you can also create a Sound object like this:

Select your sound in the library and set its 'linkage' or 'export' name to 'buttonSound'; then add this code to the main timeline of your movie...

mySound=new Sound();
mySound.attachSound('buttonSound');

...on each button add this...

on(release){
mySound.start();
//you may have to add a _root or _parent path here if your button is in a clip not on the main timeline
}

The buttons will now control the sound through code and if you need to make a change to the sound it can be done once from a 'central' location.

 
Also... As a good pratice when using the soundObject, and eventhough MM says the parameter is optional, allways add this to your soundObject's definition:

my_sound1 = new Sound(this); Regards,

oldman3.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top