Darakan
07-03-2008, 10:30 PM
I'm kind of new to Flex, so obviously I did something wrong. I'm trying to create a Database class for my project which will contain all the sound files I need through the running.
package tpow.database {
import flash.media.Sound;
import flash.media.SoundChannel;
public class DBSounds {
[Embed(source="imported/sounds/whoosh01.mp3")]
private var buttonOver : Class;
public static function playSound(string : String):void {
switch (string) {
case "buttonOver" :
var sound:Sound = new buttonOver() as Sound;
sound.play();
break;
}
}
}
}
When I want to play a sound, I just call to the playSound function like this:
tpow.database.DBSounds.playSound("buttonOver");
But I get a compilation error at the line I marked: "1180: Call to a possibly undefined method buttonOver().".
What is wrong? Is my design for this kind of idea is generally good at all (I know the "switch" isn't the best solution but I couldn't think about a different way to access multiple sounds in the future).
package tpow.database {
import flash.media.Sound;
import flash.media.SoundChannel;
public class DBSounds {
[Embed(source="imported/sounds/whoosh01.mp3")]
private var buttonOver : Class;
public static function playSound(string : String):void {
switch (string) {
case "buttonOver" :
var sound:Sound = new buttonOver() as Sound;
sound.play();
break;
}
}
}
}
When I want to play a sound, I just call to the playSound function like this:
tpow.database.DBSounds.playSound("buttonOver");
But I get a compilation error at the line I marked: "1180: Call to a possibly undefined method buttonOver().".
What is wrong? Is my design for this kind of idea is generally good at all (I know the "switch" isn't the best solution but I couldn't think about a different way to access multiple sounds in the future).