I am trying to make a sound manager class that will simplify playing a sound by
using an id string. I have embedded the sound files, but am havign trouble
getting the Sound object initialized. I get an error, "Variable beep1 is not
defined" though cllearly it is.
I suspect I am misusing getDefinitionByName. If there is an easier/better way,
I am open to that as well. The full class code is below.
Tracy
package assets.sounds
{
import flash.utils.getDefinitionByName;
import flash.media.Sound;
public class SoundManager
{
[Embed(source="beep-1.mp3")]private var beep1:Class;
[Embed(source="beep-2.mp3")]private var beep2:Class;
[Embed(source="beep-3.mp3")]private var beep3:Class;
public function playSound(sSoundName:String):void
{
var classRef:Class = getDefinitionByName(sSoundName) as Class;
//Variable beep1 is not defined.
var s:Sound = new classRef as Sound;
s.play();
}//playSound
}//class SoundManager
}//package assets.sounds