I've been spending the last 3 hours on this stupid problem so I need your help please!
The thing is that I am not able to call my "soundManager" function on the onKeyDown event with the "usrinputManager" function...
The trace "left"/"right" works, but not the "soundManager" function calling.
What's wrong?
ActionScript Code:
ActionScript Code:
class main {
private var pitch:Number = 5;
public function main() {
usrinputManager();
soundManager();
}
public function soundManager(pitchIncrement) {
trace("soundManager called");
var soundPath:String = "assets/sounds/";
var ySound:Sound = new Sound();
pitch == pitch+pitchIncrement;
ySound.loadSound(soundPath+pitch+".mp3",false);
ySound.onLoad = function(success:Boolean) {
ySound.start();
};
}
public function usrinputManager() {
trace("usrinputManager called");
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
//trace("DOWN -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii()));
switch (Key.getCode()) {
case 37 ://left key
soundManager(-1);
trace("left");
break;
case 39 ://right key
soundManager(1);
trace("right");
break;
}
};
Key.addListener(keyListener);
}
}