Prevent audio files overlapping
i developing elearning module in flash cs5 using actionscript 3.
on frames audio file plays, , timeline moves next frame.
in background of each frame 4 buttons user can click jump different section of course.
the problem having when user clicks jump different section, timeline jumps; after short delay timeframes starts jumping between old frame , new frame , playing both audio clips. suspect problem occurring if audio file has not loaded when user clicks button; first time using audio in flash wrong.
what change code when user clicks button jump somewhere else, code says stop loading audio , stop playing audio, , jump new frame.
here relevant sections of code have on layer 1, frame 1:
import flash.media.soundmixer;
// event listeners
mcwhenlarge.addeventlistener(mouseevent.click, when);
mcwhatlarge.addeventlistener(mouseevent.click, what);
// event handlers
function when(event:mouseevent):void
{
flash.media.soundmixer.stopall();
gotoandplay(7):
}
function what(event:mouseevent):void
{
gotoandplay(2);
flash.media.soundmixer.stopall();
}
layer 1 of subsequent frames looks this:
mcwhen1.addeventlistener(mouseevent.click, when);
mcwhen1.buttonmode = true;
and layer 2 of frames looks this:
import flash.net.urlrequest;
import flash.media.sound;
import flash.events.event;
var soundreq1:urlrequest = new urlrequest("recording1.mp3");
var sound1:sound = new sound();
sound1.load(soundreq1);
sound1.addeventlistener(event.complete, oncomplete1);
function oncomplete1(event:event):void
{
sound1.play();
settimeout(gotoandstop, 2000, 3);
}
any can give me stop bug appreciated.
m hetherington
would using gotoandstop() commands instead of gotoandplay() commands far not staying @ intended frames move to? (or there frames have play when arrive?)
look using soundchannel class controlling sound. consider doing have 1 sound instance redefine move along timeline, assigning new sound @ each frame.
More discussions in ActionScript 3
adobe
Comments
Post a Comment