Building a snowman with sounds


#1

You’ll see I have a broken down snowman. Each piece snaps into place when it is close enough to its corresponding target. I’d like to have one of the 4 pop sounds you’ll see in this file fire when that snap happens. I’ve attached a test file for what I’m trying to do. I have gotten it almost working a couple times. I can make it pop when I get it over the target area without a problem. But that’s not when I want the sound to fire. I need it to fire the sound after the user releases mouse and it snaps into place. I can even live with it popping again if the user moves it out of its snapped position. I can piece JS together from other files, which has gotten me where I am here, but writing from scratch is definitely not my specialty. So any help is appreciated.

opening.zip (179.4 KB)


(Hans-Gerd Claßen) #2

simply create a timeline for every sound, add a timelineaction on each which plays the sound.
when your function detects the collision start the corresponding timeline:
hypeDocument.startTimelineNamed('yourSoundTimeline', hypeDocument.kDirectionForward)


#3

Hi Hans. I’ve tried that method also. I can get it to produce the sound on collision, as I said in the first post. I’m just not advanced enough to be able to ignore the collision and have it happen only when the items snap together.

DISREGARD! Figured it out with your help. I was placing the timeline code in the wrong spot. It is working great now.