Audio will not play with AS 3
Hi, I'm using Adobe Flash CC 2015 and I have an issue that is driving me mad. I've used the old code from a working file (which apparently works in the container) but when I run it on my computer, it won't run properly when published. It plays the file, but the audio keeps looping over itself. It does not call for looping anywhere in the file properties. Here is my code:
import flash.events.MouseEvent;
import flash.events.Event;
stop();
var myChannel:SoundChannel = new SoundChannel();
this.addEventListener(Event.ENTER_FRAME, listenMe);
next_btn.addEventListener(MouseEvent.CLICK, clickNext);
prev_btn.addEventListener(MouseEvent.CLICK, clickPrev);
function clickNext(e:MouseEvent):void {
myChannel.stop();
gotoAndStop(currentFrame+1);
}
function clickPrev(e:MouseEvent):void {
myChannel.stop();
gotoAndStop(currentFrame-1);
}
function listenMe(e:Event) {
if (currentFrame == 1) {
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("audio_1.mp3"));
myChannel = mySound.play();
prev_btn.visible = false;
stop();
} else {
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("audio_2.mp3"));
myChannel = mySound.play();
prev_btn.visible = true;
}
if (currentFrame == totalFrames) {
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("audio_3.mp3"));
myChannel = mySound.play();
next_btn.visible = false;
} else {
next_btn.visible = true;
}
}
I know there is some repetitive code, but its in the original file that I'm updating and it apparently works, but not on my computer. I'm using a MAC Book Pro but running Windows 10 on it. Not sure if that is causing the problem or not. but other files seem to be running just fine.
Any help would be appreciated as I haven't used Flash in over a year.
Dee
