var dragging = false; this.onKeyUp = function() { if (Key.getCode() == Key.SPACE) { dragging = !dragging; } }; this.onMouseMove = function() { if (!dragging) { return; } myClip._x = this._xmouse; myClip._y = this._ymouse; };