hi im really new to actionscript and ive have a problem with playing sound. I want my sound to stop playing when i release the up key. ive manged to get the sound to play on a key press.
Heres my code…
import flash.events.KeyboardEvent;
var mySound:Sound = new carstart();
stage.addEventListener(KeyboardEvent.KEY_DOWN, playSound);
stage.addEventListener(KeyboardEvent.KEY_UP, stopSound);
function playSound(keyEvent:KeyboardEvent) {
if (keyEvent.keyCode == 38) {
mySound.play();
}
}
function stopSound(keyEvent:KeyboardEvent) {
if (keyEvent.keyCode == 38) {
mySound.stop();
}
}
i get this error
Scene 1, Layer 'Actions', Frame 1, Line 29 1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.
if you can think of anything it would be a great help.
thanks
1 Answer