Flash CS3 Documentation |
|||
| Developing Flash Lite 1.x Applications > Working with Sound > Using device sound > Triggering device sounds in Flash Lite 1.0 | |||
In Flash Lite 1.0, a device sound can only play in response to a user pressing a key on their device. There are two ways to satisfy this constraint. One way is to attach the sound to the Down frame in a button symbol's timeline. When the button has focus, and the user presses the Select key on their device, Flash Lite plays the sound in the button's Down frame. For an example of this technique, see Adding a device sound to a button.
The other way to trigger a device sound in Flash Lite 1.0 is to have the user press a key that sends the playhead to a frame in the timeline that contains a device sound. Any device sound at that frame plays when the playhead enters the frame.
For example, suppose your application has a button on the Stage on Frame 1, and a
device sound attached to Frame 10. You attach the following on(press) handler to the button instance:
on(press) {
gotoAndStop(10);
}
The following image shows how the application might look in Flash:
When the user select the button, the sound on Frame 10 plays. This technique requires that the device sound be attached to the same frame specified in the gotoAndPlay() function. For instance, in the example discussed above, if the sound were attached to Frame 11 rather than Frame 10, Flash Lite would not play the sound when the playback head reached Frame 11.
Flash CS3