Let's combine an audio object from the object library with some JavaScript code to make our audio clip play every time the user shakes the device:
1. We'll use our example project
Dino Stores
that we built at the beginning of the book and make the dinosaurs roar each time they shake our Shake to Change gallery. Open the project in iAd Producer now. If you haven't completed the project, you can use the6.Dino Stores - Store Finder
in theDino Stores
exercises folder.2. Open the Shake to Change page on the canvas. From the object library, add an audio object to the canvas and position it off screen so the user won't be able to see it.
3. With the object selected, expand the inspector pane and select roar-noise.m4a as the audio clip's file, as shown in the following screenshot:
4. Select the shake view object by clicking on the dinosaur image. Right-click on it and select Object Events | Did Shake | Execute JavaScript. This will open the code editor...