Hello everyone - I’m at my wit’s end at this point… I am using FlashDevelop and am trying to either play an embedded sound clip or to load it and play it: both methods aren’t working.
Here is some of what I’ve tried:
Normal embedding:
public class SoundPlayer extends Sprite
{
[Embed(source = "../../lib/sounds/levelUp.mp3")]
private const _levelUpClass:Class;
public function SoundPlayer():void
{
}
public function playLevelUp():void
{
var snd:Sound = new _levelUpClass() as Sound;
snd.play();
}
}
Loading gives me a security error: (SecurityError: Error #2000: No active security context.)
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var myTransform = new SoundTransform();
var lastPosition:Number = 0;
mySound.load(new URLRequest("../../lib/sounds/levelUp.mp3"));
myChannel = mySound.play();
myTransform.volume = 0.5;
Also, I tried adding context and got the same error:
var snd:Sound = new Sound();
var req:URLRequest = new URLRequest("../../lib/sounds/levelUp.mp3");
var context:SoundLoaderContext = new SoundLoaderContext(0, true);
snd.load(req, context);
snd.play();
I don’t really care how the sound is played, but I need it to play… this is the first time I’ve worked with sounds in AS3 (first time I’ve needed to).
Any ideas?
EDIT: hey folks, I figured out that the file was semi-corrupt, for lack of a better term. It worked in other music players, but not in Flash… I replaced the file and voila!