This content has been marked as final. Show 4 replies
Seems iffy placing the sound instance within a button symbol timeline ... I would go about this a different way.
create a Sound Object on the main timeline, and control it's play by using an on handler for the corresponding button.
You will need to add a 'linkage identifier' to the sound file in the library, select it, right click, select linkage identifier, select export for AS, and type in a name (I used 'sound_id' in the code below), then add code like this from the main timeline:
clbeech - Thanks for the response.
Your code worked in the develpment environment but not in the published version. When I tested the individual swf with the buttons - it worked. This is the swf with the sound object on its main timeline.
I don't know if it matters but this swf is part of a large project (its Topic 5 of 55 Topics). When I tested the whole project, navigated to Topic 5, the button sounds did not fire. I tried putting the sound object on the master timeline and that didn't work.
hmmm... interesting, i wonder what the deal is here. Have you used this sound elsewhere within the overall master? It seems like it's not getting publish properly or something, could be part of the edit you made? not sure.
Maybe try aceing the file and re-importing it, could be that it got corrupted in the transfer process somehow, or maybe somethings wrong with the individual file itself.
I've run across instances when after import, all sounds won't play until I shut down Flash and reboot the program, but this doesn't seem to be the problem here, so ... dunno, weird.
EDIT: here's a though, do you have any other sound Objects in that particular file, that might have the volume set to 0? this would effect all sounds globally. (but only if it's a Sound Object I think, not on the timeline, not sure if it functions the same from there)
Thanks for sticking with me on this.
I worked it out and, like most of my AS - it is messy. I'm sure there is a better way to do this but here's what I have so far.
First I need to set the stage - forgive any repetition. My project is constructed starting with one swf that is only a preloader. The "Start.swf" is the first thing the user sees but they do not interact with it. The "Start.swf" then loads the main "master.swf" which is the overall GUI. From the master, the user navigates and loads in all other Topic swfs into itself.
That being established, what I've discovered is that all the sound files have to be in the Library of the Start.swf - not the master.swf - with the correct Linkage settings. Also in the actions layer of the Start.swf I used your code to declare a var with the new Sound object, attachSound and also setVolume to 100. (I was only able to get the desired volume by editing the wav file outside of Flash - but that's another topic for the forum.)
Now to Topic55.swf . This is an "inner swf" that the user can access by clicking a link on the master GUI. It's the one with the 3 button instances that started this thread. As you suggested I took the sound off of the timeline of the btns. I found that the wav (or mp3) file must also be in that Topic55.swf Library with the same Linkage ID as in the Start.swf (so I copied and pasted the snd files from one Library to the other).
Then in the movie clip within Topic55 that actually has the onRelease code for the buttons I want to hear I put your same code: declare a var with a new Sound object and attach it. I did not setVolume here. Then in the onRelease function statement of the button I put the start() .
That's my story and I'm sticking to it.