
Код:
class Zig_game.Bul extends MovieClip {
var shoot:Boolean;
var shootID:Number;
var depth:Number;
// Конструктор
function Bul() {
var thisInstance=this //ссылка на экземпляр
shoot = true;
depth = _root.getNextHighestDepth();
Key.addListener(this);
this.onKeyDown = function() {
if (Key.getCode() == Key.SPACE && shoot) {
trace(shoot); // выдаёт true
shoot = false;
trace(shoot); // выдаёт false
shootID = setInterval(enableShoot, 1000, thisInstance); // передаем ссылку на экземпляр
depth++;
}
};
}
function enableShoot(thisInstance):Void {
thisInstance.shoot = true;
trace(thisInstance.shoot); // должно выдавать true
clearInterval(shootID);
}
}