Page 1 of 1

Trigger sound events via script

PostPosted: Tue Jun 22, 2010 11:23 am
by Lyberodoggy
A lot of you guys where concerned when the newest version of AM disabled the option to trigger sounds via scripting. Well, me too. But while working on a project I figured a temporary workaround.

Well the concept is quite simple. You need an amount of sounds to be triggered on a frame through code. In older versions, you just needed to have the sounds in the external folder and then use the custom sub PlaySound included in the help files.
Now what I thought is: At first create the same amount of hotspots as the sounds needed. You need to play five sounds? Create five different hotspots and keep their numbers in mind.
Go to the hotspots' sound tab and add one sound per hotspot.
Then drag and drop every hotspot on top of each other and create a bigger hotspot over them with no action at all (this will prevent the user from clicking the sound hotspots by accident)

Now all you have to do is trigger the hotspot using
SimulateHotspotClick hotspot_number
in the code that should trigger the sound.

PostPosted: Wed Jun 23, 2010 4:54 am
by Mystery
I didn't know that the PlaySound command was disabled, I just thought that it wouldn't work for Windows 7. But since I haven't used the new beta version, I don't know.

Anyhow, your workaround would work for Windows 7?

PostPosted: Wed Jun 23, 2010 1:26 pm
by Lyberodoggy
yes, since the sound tabs work

PostPosted: Wed Jun 23, 2010 10:52 pm
by Imari
Nice, Lyberodoggy. :)