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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

event trigger on movie collision

Status
Not open for further replies.

crowds

Technical User
Aug 22, 2004
3
GB
Im trying to trigger some sound when movies collide (for a very basic game im doing for my 5 year old son). I have created a movie clip of an animated man walking. Inside of this movie clip i have created another clip which i intend to use as the hot spot for triggering sounds. This is all well and good but i cant sort out the action script need to trigger the sounds. Any tutorials i have found have all been for earlier versions of flash and therefore wont workwith the new action script. I also need to to you the collide movie function to load a new movie when the animated charector reaches his destination. This i would imagine would be very similar to the script needed for the sound trigger. Can anyone please help me with this or point me in the right direction for some tutorials? I promised him it would be done for the weekend (silly me)
Cheers
Crowds
 
Ok ive posted this on another forum and got the following

soundTrigger = function(){
var doSound = character_mc.hitTest("soundTrigger_mc");
if(doSound == true){
//statement to play the sound.
clearInterval(characterWatch);
}
}
characterWatch = setInterval(soundTrigger, 500); //execute every half-second

character_mc would be replaced by the name of my animated character and
soundtrigger_mc would be replaced by the name of the movie that my character collides with.....
Do i add this script to the character mc or the soundtrigger mc? and how do i point it to the sound that i want to play?
for instance if its a Wav file in my libary called ping.wav or do i actualy have to add the wav to the soundtrigger mc ?
Cheers
Crowds
 
That function would go on the main timeline - I usually put all scripts in the first frame so I know where to find them.

To trigger the actual sound it would need to be set up as a sound object (this code can be set up in the first frame of the main timeline too):

Code:
mySound=new Sound();
mySound.attachSound('ping');// where 'ping' is the linkage name of your sound from the library (right click on the file itself to set this name)

the sound itself would be played from the function like this:

Code:
mySound.start()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top