Game Development Reference
In-Depth Information
Finishing up the Library class
The sounds are special case, as they require assets, which you must either create yourself or
download from the web site for this topic. We will embedding
.mp3
sounds directly inside Flex
SDK AS3 applications (with a Flex embed) in Chapters 10 and 11. For now, we will use the same
method we used in Chapters 4 and 5. You will need to embed your sounds in a
.fla
, give them
the linkage names that match the
Library.as
class (which comes next), and export them as
noTanks_assets.swf
. You will need to place this file in the assets folder for the project. There is
no need for this file if you are using the Flash IDE. In that case, simply import in the sounds and
set the linkage identifiers to the names in the class (this code will come next).
Here is the location in the framework for this file:
/source/projects/notanks/flexSDK/assets/noTaks_assets.swf
We will add new assets to our
Library.as
to handle each of the sounds we need. As a refresher,
the location for this file will be:
/source/projects/notanks/flexSDK/src/com/efg/games/notanks/Library.as
Here is the new
Library.as
file with the assets embedded using the
noTanks_assets.swf
as the
source of the sounds:
package com.efg.games.notanks
{
import flash.display.Bitmap;
import flash.display.BitmapData;
public class Library {
[Embed(source='../../../../../assets/tanks_sheet.png')]
public static const TankSheetPng:Class;
[Embed(source = "../../../../../assets/noTanks_assets.swf",
symbol="soundEnemyFire")]
public static const SoundEnemyFire:Class;
[Embed(source = "../../../../../assets/noTanks_assets.swf", symbol="soundExplode")]
public static const SoundExplode:Class;
[Embed(source = "../../../../../assets/noTanks_assets.swf",
symbol="soundPlayerExplode")]
public static const SoundPlayerExplode:Class;
[Embed(source = "../../../../../assets/noTanks_assets.swf",
symbol="soundPlayerFire")]
public static const SoundPlayerFire:Class;
[Embed(source = "../../../../../assets/noTanks_assets.swf",
symbol="soundPlayerMove")]
public static const SoundPlayerMove:Class;
[Embed(source = "../../../../../assets/noTanks_assets.swf", symbol="soundPickUp")]
public static const SoundPickUp:Class;