Hi all. I’ve been working on a game lately, and I’ve been trying to add sound effects and music, but can’t for the life of me get either to work. I’m working in FlashDevelop (version 4.0.0.0) and I’ve looked up numerous tutorials on this, but nothing has worked. I created a blank project just for the sake of testing sound, to see if the issue would persist outside my game, and it did. Here is my code:
package {
import flash.display.Sprite;
import flash.events.Event;
import Class;
import flash.media.Sound;
import flash.display.Stage;
public class Main extends Sprite
{
[Embed(source="../lib/hitSound.wav", mimeType="application/octet-stream")]
private var soundClass:Class;
private var mySound:Sound;
public function Main():void
{
mySound = (new soundClass) as Sound;
mySound.play();
}
}
}
And here is the error that pops up:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main()
The sound, by the way, works fine in Windows Movie Maker (it’s a simple “bleep” sound). I’m sure this is a simple fix, but I never had this issue when I worked with Flash Professional. Hopefully someone here can help.