Game Development Reference
In-Depth Information
limitation, but with the added headache of trying to avoid the space of silence at the beginning of
the .mp3 file. We will use a an offset to skip this space when we play our sounds.
Here's a note about MP3 silence space: MP3-formatted files have a section of data at the beginning
where the ID3 tag and other file specific information are stored. When you play the file, there is a
short silence at the beginning of the file before the sound starts. This silence is almost unnoticeable
when you play a song that does not loop. When a looping sound or piece of music is played, this
silence will be pronounced and cause an audible delay between the end of the sound play and the
start of the next play of the sound. Luckily, the AS3 sound handler functions allow us to skip into the
play of a sound by an offset, which helps us to skip the silence when we loop a sound.
Some MP3 file encoders also leave some silence at the end of the file. Unfortunately, there is no
built-in ending offset in the AS3 sound handlers.
If you are using the Flash IDE, you should import the sounds into the library and use the class
names in the Library class as your linkage names. You do not need the Library class for the
Flash IDE version.
This is the folder structure for this file in the Flex SDK (using Flash Develop):
/source/projects/driveshesaid/flexSDK/src/com/efg/games/driveshesaid/Library.as
Use the following code to create the file at that location:
package com.efg.games.driveshesaid
{
public class Library {
[Embed(source = "../../../../../assets/tile_sheet.png")]
public static const TileSheetPng:Class;
[Embed(source="../../../../../assets/sound_titlemusic.mp3")]
public static const SoundTitleMusic:Class;
[Embed(source="../../../../../assets/sound_car.mp3")]
public static const SoundCar:Class;
[Embed(source="../../../../../assets/sound_clockpickup.mp3")]
public static const SoundClockPickup:Class;
[Embed(source="../../../../../assets/sound_heartpickup.mp3")]
public static const SoundHeartPickup:Class;
[Embed(source="../../../../../assets/sound_gamelost.mp3")]
public static const SoundGameLost:Class;
[Embed(source="../../../../../assets/sound_levelcomplete.mp3")]
public static const SoundLevelComplete:Class;
[Embed(source="../../../../../assets/sound_skullhit.mp3")]
public static const SoundSkullHit :Class;
[Embed(source="../../../../../assets/sound_playerstart.mp3")]
public static const SoundPlayerStart:Class;
Search WWH ::




Custom Search