Frame 1
var tween = (new mx.transitions.Tween(null, "_alpha", mx.transitions.easing.Back.easeIn, 0, 100, 1, true));
mx.transitions.easing.None;
mx.transitions.easing.Elastic;
com.lumoslabs.games.nback.speedmatch.SpeedMatchContainer.main();
Instance of Symbol 103 MovieClip [Loader] in Symbol 104 MovieClip [lumosLogo] Frame 1
onClipEvent (load) {
total = _root.getBytesTotal();
}
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
percent = int((loaded / total) * 100);
txtpercent.text = (((((percent + "%") + " : ") + loaded) + " Kb of ") + total) + " Kb";
text = percent + "%";
gotoAndStop(percent);
if (loaded == total) {
}
}
Symbol 125 MovieClip [prompt_mc] Frame 1
stop();
Symbol 125 MovieClip [prompt_mc] Frame 5
stop();
Symbol 183 MovieClip [yes_btn] Frame 1
stop();
Symbol 183 MovieClip [yes_btn] Frame 5
stop();
Symbol 188 MovieClip [no_btn] Frame 1
stop();
Symbol 188 MovieClip [no_btn] Frame 5
stop();
Symbol 258 MovieClip [help_mc] Frame 1
#initclip 92
Object.registerClass("help_mc", com.lumoslabs.games.nback.speedmatch.SpeedMatchHelpScreen);
#endinitclip
stop();
play_button.onRelease = function () {
endDemo();
};
question_button.onRelease = function () {
gotoAndPlay ("screen1");
};
Symbol 258 MovieClip [help_mc] Frame 36
function onAnyKey() {
gotoAndPlay ("screen2");
}
go_button.onRelease = function () {
onAnyKey();
};
Symbol 258 MovieClip [help_mc] Frame 251
stop();
Symbol 258 MovieClip [help_mc] Frame 252
function onAnyKey() {
}
function onYes() {
gotoAndPlay ("screen2_wrong");
}
function onNo() {
gotoAndPlay ("screen2_right");
}
yes_button.onRelease = function () {
onYes();
};
no_button.onRelease = function () {
onNo();
};
yes_button.enabled = true;
no_button.enabled = true;
Symbol 258 MovieClip [help_mc] Frame 399
stop();
Symbol 258 MovieClip [help_mc] Frame 400
Symbol 258 MovieClip [help_mc] Frame 434
gotoAndPlay ("screen3");
Symbol 258 MovieClip [help_mc] Frame 435
stop();
Symbol 258 MovieClip [help_mc] Frame 468
function onYes() {
gotoAndPlay ("screen3_right");
}
function onNo() {
gotoAndPlay ("screen3_wrong");
}
Symbol 258 MovieClip [help_mc] Frame 537
stop();
Symbol 258 MovieClip [help_mc] Frame 538
stop();
Symbol 258 MovieClip [help_mc] Frame 575
Symbol 258 MovieClip [help_mc] Frame 610
function onYes() {
gotoAndPlay ("screen4_right");
}
function onNo() {
gotoAndPlay ("screen4_wrong");
}
Symbol 258 MovieClip [help_mc] Frame 677
stop();
Symbol 258 MovieClip [help_mc] Frame 678
stop();
Symbol 258 MovieClip [help_mc] Frame 715
Symbol 258 MovieClip [help_mc] Frame 750
function onYes() {
gotoAndPlay ("screen5_wrong");
}
function onNo() {
gotoAndPlay ("screen5_right");
}
Symbol 258 MovieClip [help_mc] Frame 820
stop();
Symbol 258 MovieClip [help_mc] Frame 821
stop();
Symbol 258 MovieClip [help_mc] Frame 858
function onYes() {
}
function onNo() {
}
stop();
play_button.onRelease = function () {
endDemo();
};
question_button.onRelease = function () {
gotoAndPlay ("screen1");
};
yes_button.enabled = false;
no_button.enabled = false;
Symbol 268 MovieClip [__Packages.mx.transitions.OnEnterFrameBeacon] Frame 0
class mx.transitions.OnEnterFrameBeacon
{
function OnEnterFrameBeacon () {
}
static function init() {
var _local4 = _global.MovieClip;
if (!_root.__OnEnterFrameBeacon) {
mx.transitions.BroadcasterMX.initialize(_local4);
var _local3 = _root.createEmptyMovieClip("__OnEnterFrameBeacon", 9876);
_local3.onEnterFrame = function () {
_global.MovieClip.broadcastMessage("onEnterFrame");
};
}
}
static var version = "1.1.0.52";
}
Symbol 269 MovieClip [__Packages.mx.transitions.BroadcasterMX] Frame 0
class mx.transitions.BroadcasterMX
{
var _listeners;
function BroadcasterMX () {
}
static function initialize(o, dontCreateArray) {
if (o.broadcastMessage != undefined) {
delete o.broadcastMessage;
}
o.addListener = mx.transitions.BroadcasterMX.prototype.addListener;
o.removeListener = mx.transitions.BroadcasterMX.prototype.removeListener;
if (!dontCreateArray) {
o._listeners = new Array();
}
}
function addListener(o) {
removeListener(o);
if (broadcastMessage == undefined) {
broadcastMessage = mx.transitions.BroadcasterMX.prototype.broadcastMessage;
}
return(_listeners.push(o));
}
function removeListener(o) {
var _local2 = _listeners;
var _local3 = _local2.length;
while (_local3--) {
if (_local2[_local3] == o) {
_local2.splice(_local3, 1);
if (!_local2.length) {
broadcastMessage = undefined;
}
return(true);
}
}
return(false);
}
function broadcastMessage() {
var _local5 = String(arguments.shift());
var _local4 = _listeners.concat();
var _local6 = _local4.length;
var _local3 = 0;
while (_local3 < _local6) {
_local4[_local3][_local5].apply(_local4[_local3], arguments);
_local3++;
}
}
static var version = "1.1.0.52";
}
Symbol 270 MovieClip [__Packages.mx.transitions.Tween] Frame 0
class mx.transitions.Tween
{
var obj, prop, begin, useSeconds, _listeners, addListener, prevTime, _time, looping, _duration, broadcastMessage, isPlaying, _fps, prevPos, _pos, change, _intervalID, _startTime;
function Tween (obj, prop, func, begin, finish, duration, useSeconds) {
mx.transitions.OnEnterFrameBeacon.init();
if (!arguments.length) {
return;
}
this.obj = obj;
this.prop = prop;
this.begin = begin;
position = (begin);
this.duration = (duration);
this.useSeconds = useSeconds;
if (func) {
this.func = func;
}
this.finish = (finish);
_listeners = [];
addListener(this);
start();
}
function set time(t) {
prevTime = _time;
if (t > duration) {
if (looping) {
rewind(t - _duration);
update();
broadcastMessage("onMotionLooped", this);
} else {
if (useSeconds) {
_time = _duration;
update();
}
stop();
broadcastMessage("onMotionFinished", this);
}
} else if (t < 0) {
rewind();
update();
} else {
_time = t;
update();
}
//return(time);
}
function get time() {
return(_time);
}
function set duration(d) {
_duration = (((d == null) || (d <= 0)) ? (_global.Infinity) : (d));
//return(duration);
}
function get duration() {
return(_duration);
}
function set FPS(fps) {
var _local2 = isPlaying;
stopEnterFrame();
_fps = fps;
if (_local2) {
startEnterFrame();
}
//return(FPS);
}
function get FPS() {
return(_fps);
}
function set position(p) {
setPosition(p);
//return(position);
}
function setPosition(p) {
prevPos = _pos;
obj[prop] = (_pos = p);
broadcastMessage("onMotionChanged", this, _pos);
updateAfterEvent();
}
function get position() {
return(getPosition());
}
function getPosition(t) {
if (t == undefined) {
t = _time;
}
return(func(t, begin, change, _duration));
}
function set finish(f) {
change = f - begin;
//return(finish);
}
function get finish() {
return(begin + change);
}
function continueTo(finish, duration) {
begin = position;
this.finish = (finish);
if (duration != undefined) {
this.duration = (duration);
}
start();
}
function yoyo() {
continueTo(begin, time);
}
function startEnterFrame() {
if (_fps == undefined) {
_global.MovieClip.addListener(this);
} else {
_intervalID = setInterval(this, "onEnterFrame", 1000 / _fps);
}
isPlaying = true;
}
function stopEnterFrame() {
if (_fps == undefined) {
_global.MovieClip.removeListener(this);
} else {
clearInterval(_intervalID);
}
isPlaying = false;
}
function start() {
rewind();
startEnterFrame();
broadcastMessage("onMotionStarted", this);
}
function stop() {
stopEnterFrame();
broadcastMessage("onMotionStopped", this);
}
function resume() {
fixTime();
startEnterFrame();
broadcastMessage("onMotionResumed", this);
}
function rewind(t) {
_time = ((t == undefined) ? 0 : (t));
fixTime();
update();
}
function fforward() {
time = (_duration);
fixTime();
}
function nextFrame() {
if (useSeconds) {
time = ((getTimer() - _startTime) / 1000);
} else {
time = (_time + 1);
}
}
function onEnterFrame() {
nextFrame();
}
function prevFrame() {
if (!useSeconds) {
time = (_time - 1);
}
}
function toString() {
return("[Tween]");
}
function fixTime() {
if (useSeconds) {
_startTime = getTimer() - (_time * 1000);
}
}
function update() {
position = (getPosition(_time));
}
static var version = "1.1.0.52";
static var __initBeacon = mx.transitions.OnEnterFrameBeacon.init();
static var __initBroadcaster = mx.transitions.BroadcasterMX.initialize(mx.transitions.Tween.prototype, true);
function func(t, b, c, d) {
return(((c * t) / d) + b);
}
}
Symbol 271 MovieClip [__Packages.mx.transitions.easing.Elastic] Frame 0
class mx.transitions.easing.Elastic
{
function Elastic () {
}
static function easeIn(t, b, c, d, a, p) {
if (t == 0) {
return(b);
}
t = t / d;
if (t == 1) {
return(b + c);
}
if (!p) {
p = d * 0.3;
}
if ((!a) || (a < Math.abs(c))) {
a = c;
var _local7 = p / 4;
} else {
var _local7 = (p / (Math.PI*2)) * Math.asin(c / a);
}
t = t - 1;
return((-((a * Math.pow(2, 10 * t)) * Math.sin((((t * d) - _local7) * (Math.PI*2)) / p))) + b);
}
static function easeOut(t, b, c, d, a, p) {
if (t == 0) {
return(b);
}
t = t / d;
if (t == 1) {
return(b + c);
}
if (!p) {
p = d * 0.3;
}
if ((!a) || (a < Math.abs(c))) {
a = c;
var _local7 = p / 4;
} else {
var _local7 = (p / (Math.PI*2)) * Math.asin(c / a);
}
return((((a * Math.pow(2, -10 * t)) * Math.sin((((t * d) - _local7) * (Math.PI*2)) / p)) + c) + b);
}
static function easeInOut(t, b, c, d, a, p) {
if (t == 0) {
return(b);
}
t = t / (d / 2);
if (t == 2) {
return(b + c);
}
if (!p) {
p = d * 0.45;
}
if ((!a) || (a < Math.abs(c))) {
a = c;
var _local7 = p / 4;
} else {
var _local7 = (p / (Math.PI*2)) * Math.asin(c / a);
}
if (t < 1) {
t = t - 1;
return((-0.5 * ((a * Math.pow(2, 10 * t)) * Math.sin((((t * d) - _local7) * (Math.PI*2)) / p))) + b);
}
t = t - 1;
return(((((a * Math.pow(2, -10 * t)) * Math.sin((((t * d) - _local7) * (Math.PI*2)) / p)) * 0.5) + c) + b);
}
static var version = "1.1.0.52";
}
Symbol 272 MovieClip [__Packages.mx.transitions.easing.Back] Frame 0
class mx.transitions.easing.Back
{
function Back () {
}
static function easeIn(t, b, c, d, s) {
if (s == undefined) {
s = 1.70158;
}
t = t / d;
return((((c * t) * t) * (((s + 1) * t) - s)) + b);
}
static function easeOut(t, b, c, d, s) {
if (s == undefined) {
s = 1.70158;
}
t = (t / d) - 1;
return((c * (((t * t) * (((s + 1) * t) + s)) + 1)) + b);
}
static function easeInOut(t, b, c, d, s) {
if (s == undefined) {
s = 1.70158;
}
t = t / (d / 2);
if (t < 1) {
s = s * 1.525;
return(((c / 2) * ((t * t) * (((s + 1) * t) - s))) + b);
}
t = t - 2;
s = s * 1.525;
return(((c / 2) * (((t * t) * (((s + 1) * t) + s)) + 2)) + b);
}
static var version = "1.1.0.52";
}
Symbol 273 MovieClip [__Packages.com.lumoslabs.framework.ManagedGame] Frame 0
interface com.lumoslabs.framework.ManagedGame
{
}
Symbol 274 MovieClip [__Packages.com.lumoslabs.framework.GameManager] Frame 0
interface com.lumoslabs.framework.GameManager
{
}
Symbol 275 MovieClip [__Packages.com.lumoslabs.games.GameContainer] Frame 0
class com.lumoslabs.games.GameContainer implements com.lumoslabs.framework.ManagedGame
{
var target_mc, depth, xLoc, yLoc, container_mc, settings, game, manager;
function GameContainer (target_mc, depth, x, y) {
Stage.align = "TL";
Stage.scaleMode = "noScale";
this.target_mc = target_mc;
this.depth = depth;
xLoc = x;
yLoc = y;
setupContainerClip();
setDefaults();
com.lumoslabs.framework.GameRegistrar.registerGame(this);
}
function setupContainerClip() {
container_mc.onEnterFrame = undefined;
delete container_mc.onEnterFrame;
container_mc.removeMovieClip();
container_mc = target_mc.createEmptyMovieClip("container_mc", depth);
container_mc._x = xLoc;
container_mc._y = yLoc;
}
function setDefaults() {
}
function init(obj) {
initGame(obj);
}
function initGame(obj) {
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.PlayEvent) {
reportPlay();
} else if (infoObj instanceof com.lumoslabs.games.HelpEvent) {
reportReset();
} else if (infoObj instanceof com.lumoslabs.games.FinalFinish) {
reportQuit();
} else if (infoObj instanceof com.lumoslabs.games.PromoEvent) {
reportPromo();
}
}
function fetchData(obj) {
}
function finish(obj, str) {
trace("GameContainer: Passing data");
reportData(obj);
}
function addSettings(gameSettings) {
trace("GameContainer: Adding settings");
settings = gameSettings;
}
function start() {
initGame(settings);
}
function help() {
game.help();
}
function mute() {
game.toggleMute();
}
function pause() {
game.togglePause();
}
function registerManager(newManager) {
manager = newManager;
}
function removeManager() {
delete manager;
}
function isPausable() {
return(_isPausable);
}
function isFullScreen() {
return(_isFullScreen);
}
function destroy() {
}
function reportPlay() {
manager.onPlay(this);
}
function reportData(gameData) {
manager.onData(this, gameData);
}
function reportReset() {
manager.onReset(this);
}
function reportQuit() {
trace("GameContainer: Calling report quit");
manager.onQuit(this);
}
function reportPromo() {
manager.onPromo(this);
}
var _isPausable = false;
var _isFullScreen = false;
var result = new Object();
}
Symbol 276 MovieClip [__Packages.com.lumoslabs.util.Observable] Frame 0
class com.lumoslabs.util.Observable
{
var observers;
function Observable () {
observers = new Array();
}
function addObserver(o) {
if (o == null) {
return(false);
}
var _local2 = 0;
while (_local2 < observers.length) {
if (observers[_local2] == o) {
return(false);
}
_local2++;
}
observers.push(o);
return(true);
}
function removeObserver(o) {
var _local3 = observers.length;
var _local2 = 0;
while (_local2 < _local3) {
if (observers[_local2] == o) {
observers.splice(_local2, 1);
return(true);
}
_local2++;
}
return(false);
}
function notifyObservers(infoObj) {
if (infoObj == undefined) {
infoObj = null;
}
if (!changed) {
return(undefined);
}
var _local3 = observers.slice(0);
clearChanged();
var _local2 = _local3.length - 1;
while (_local2 >= 0) {
_local3[_local2].update(this, infoObj);
_local2--;
}
}
function clearObservers() {
observers = new Array();
}
function setChanged() {
changed = true;
}
function clearChanged() {
changed = false;
}
function hasChanged() {
return(changed);
}
function countObservers() {
return(observers.length);
}
function getObservers() {
return(observers.slice(0));
}
var changed = false;
}
Symbol 277 MovieClip [__Packages.com.lumoslabs.util.Observer] Frame 0
interface com.lumoslabs.util.Observer
{
}
Symbol 278 MovieClip [__Packages.com.lumoslabs.games.Game] Frame 0
class com.lumoslabs.games.Game extends com.lumoslabs.util.Observable
{
var score, level, running, levelChanged, setChanged, bestScore, finalScoresArray, lives, trialsRemaining, startTime, notifyObservers, soundEffects;
function Game () {
super();
score = 0;
level = 0;
running = false;
levelChanged = false;
}
function addPoints(points) {
newPoints = points;
score = score + newPoints;
if (score < 0) {
score = 0;
}
setChanged();
doUpdate();
}
function getLevel() {
return(level);
}
function getLevelChanged() {
return(levelChanged);
}
function getScore() {
return(score);
}
function updateBestScore() {
if ((score > bestScore) || (isNaN(bestScore))) {
bestScore = score;
}
}
function getBestScore() {
return(bestScore);
}
function pushFinalScore() {
if (finalScoresArray == null) {
finalScoresArray = new Array();
}
finalScoresArray.push(score);
}
function getFinalScoresArray() {
return(finalScoresArray);
}
function isRunning() {
return(running);
}
function levelUp() {
level = level + 1;
setLevel(level);
}
function onClick(x, y) {
}
function setLevel(newLevel) {
level = newLevel;
levelChanged = true;
setChanged();
doUpdate();
clearChanged();
}
function setScore(newScore) {
score = newScore;
setChanged();
doUpdate();
}
function setLives(lives) {
this.lives = lives;
}
function getLives() {
return(lives);
}
function changeLives(change) {
lives = lives + change;
}
function setTrialsRemaining(trialsRemaining) {
this.trialsRemaining = trialsRemaining;
if (trialsRemaining == 0) {
}
setChanged();
doUpdate();
}
function start() {
startTime = getTimer();
running = true;
setChanged();
doUpdate();
run();
}
function stop() {
running = false;
}
function restart() {
reset();
start();
}
function sendResults(resultObj) {
var _local3 = new com.lumoslabs.util.ResultSet(resultObj);
debug("results are:");
debug(_local3.toString());
var _local2 = new XML();
_local2.onLoad = com.lumoslabs.util.Delegate.create(this, resultsSent);
debug("sending data to " + save_url);
_local3.send(save_url, _local2);
}
function resultsSent(success) {
if (success) {
debug("transfer was successful");
} else {
debug("transfer failed");
}
}
function debug(str) {
setChanged();
notifyObservers(new com.lumoslabs.games.DebugOutput(str));
}
function reset() {
stop();
score = 0;
newPoints = 0;
level = 0;
running = false;
levelChanged = false;
finalScoresArray = [];
setChanged();
notifyObservers(new com.lumoslabs.games.ResetEvent());
}
function clearChanged() {
super.clearChanged();
levelChanged = false;
}
function doUpdate() {
notifyObservers(new com.lumoslabs.games.GameState(score, level, running, levelChanged, newPoints, trialsRemaining));
}
function run() {
}
function init(obj) {
}
function finish() {
}
function finalFinish() {
trace("firing final event");
setChanged();
notifyObservers(new com.lumoslabs.games.FinalFinish());
}
function help() {
setChanged();
notifyObservers(new com.lumoslabs.games.HelpEvent());
}
function getSounds() {
return(soundEffects);
}
function toggleMute() {
return(soundEffects.toggleMute());
}
function togglePause() {
return(false);
}
static var LEVEL_INCREMENT = 1000;
var newPoints = 0;
var save_url = "http://localhost/foo/";
static var EASY = 0;
static var MEDIUM = 1;
static var HARD = 2;
static var TEST = 3;
}
Symbol 279 MovieClip [__Packages.com.lumoslabs.games.SoundEffects] Frame 0
class com.lumoslabs.games.SoundEffects
{
static var firstLoadedTarget;
var all_sounds, context_mc, mute, pause, positiveFeedback, negativeFeedback, tier1Sound, tier2Sound, tier3Sound, tier4Sound, ambientSound;
function SoundEffects (target) {
if (firstLoadedTarget == undefined) {
firstLoadedTarget = target;
}
all_sounds = [];
firstLoadedTarget.createEmptyMovieClip("context_mc", firstLoadedTarget.getNextHighestDepth());
context_mc = firstLoadedTarget.context_mc;
mute = false;
pause = false;
}
function addSound(id) {
var _local2 = new com.lumoslabs.games.GameSound(context_mc);
_local2.attachSound(id);
_local2.setVolume(volume);
_local2.setMute(mute);
_local2.setPause(pause);
all_sounds.push(_local2);
return(_local2);
}
function playFeedbackSound(isPositive) {
if (isPositive) {
positiveFeedback.start(0, 1);
} else {
negativeFeedback.start(0, 1);
}
}
function playTieredFeedbackSound(tier) {
if (tier == 1) {
tier1Sound.start(0, 1);
} else if (tier == 2) {
tier2Sound.start(0, 1);
} else if (tier == 3) {
tier3Sound.start(0, 1);
} else if (tier == 4) {
tier4Sound.start(0, 1);
} else {
negativeFeedback.start(0, 1);
}
}
function setAmbientSound(newSound) {
ambientSound = newSound;
ambientSound.loop = true;
}
function setTieredSounds(sound1, sound2, sound3, sound4) {
tier1Sound = sound1;
tier2Sound = sound2;
tier3Sound = sound3;
tier4Sound = sound4;
}
function setPositiveFeedbackSound(newSound) {
positiveFeedback = newSound;
}
function setNegativeFeedbackSound(newSound) {
negativeFeedback = newSound;
}
function startAmbientSound() {
ambientSound.start(0, 1);
}
function stopAmbientSound() {
ambientSound.stop();
}
function stopAllSounds() {
for (var _local2 in all_sounds) {
com.lumoslabs.games.GameSound(all_sounds[_local2]).stop();
}
}
function setMute(mute) {
this.mute = mute;
for (var _local3 in all_sounds) {
com.lumoslabs.games.GameSound(all_sounds[_local3]).setMute(mute);
}
}
function toggleMute() {
setMute(!mute);
return(mute);
}
function destroy() {
stopAllSounds();
if (ambientSound) {
stopAmbientSound();
}
context_mc.removeMovieClip();
}
function setPause(pause) {
this.pause = pause;
for (var _local3 in all_sounds) {
com.lumoslabs.games.GameSound(all_sounds[_local3]).setPause(pause);
}
}
function togglePause() {
setPause(!pause);
return(pause);
}
var volume = 40;
}
Symbol 280 MovieClip [__Packages.com.lumoslabs.games.GameSound] Frame 0
class com.lumoslabs.games.GameSound extends Sound
{
var play, pause, mute, volume, loop, position;
function GameSound () {
if (arguments.length > 0) {
super(arguments[0]);
} else {
super();
}
play = false;
pause = false;
mute = false;
volume = super.getVolume();
loop = false;
}
function start() {
switch (arguments.length) {
case 0 :
super.start();
break;
case 1 :
super.start(arguments[0]);
break;
default :
super.start(arguments[0], arguments[1]);
}
if (pause) {
super.stop();
}
play = true;
}
function stop() {
if (arguments.length > 0) {
super.stop(arguments[0]);
} else {
super.stop();
}
play = false;
pause = false;
}
function getVolume() {
return(volume);
}
function setVolume(value) {
super.setVolume(value);
volume = super.getVolume();
if (mute) {
super.setVolume(0);
}
}
function getPlay() {
return(play);
}
function setPause(pause) {
if (pause) {
doPause();
} else {
unPause();
}
}
function setMute(mute) {
this.mute = mute;
if (mute) {
super.setVolume(0);
} else {
super.setVolume(volume);
}
}
function doPause() {
if (!pause) {
pause = true;
if (play) {
super.stop();
}
}
}
function unPause() {
if (pause) {
pause = false;
if (play) {
super.start(position / 1000);
}
}
}
function onSoundComplete() {
if (loop) {
start();
} else {
play = false;
pause = false;
}
}
}
Symbol 281 MovieClip [__Packages.com.lumoslabs.util.ResultSet] Frame 0
class com.lumoslabs.util.ResultSet
{
var resultXML;
function ResultSet (resultObj) {
buildXML(resultObj);
}
function buildXML(resultObj) {
resultXML = new XML();
var _local9 = resultObj.session_id;
if (!(delete resultObj.session_id)) {
_local9 = _root.session_id;
if (_local9 == undefined) {
return(undefined);
}
}
var _local8 = resultXML.createElement("session");
resultXML.appendChild(_local8);
var _local10 = resultXML.createElement("id");
_local8.appendChild(_local10);
_local10.appendChild(resultXML.createTextNode(_local9));
var _local6 = resultXML.createElement("game");
_local8.appendChild(_local6);
var _local4;
var _local5;
for (var _local7 in resultObj) {
trace((("adding node: " + _local7) + " value: ") + resultObj.prop);
_local4 = resultXML.createElement(_local7);
_local5 = resultXML.createTextNode(resultObj[_local7]);
_local6.appendChild(_local4);
_local4.appendChild(_local5);
}
trace(resultXML);
}
function toString() {
return(resultXML.toString());
}
function send(url, response) {
resultXML.contentType = "text/xml";
}
}
Symbol 282 MovieClip [__Packages.com.lumoslabs.util.Delegate] Frame 0
class com.lumoslabs.util.Delegate
{
function Delegate () {
}
static function create(scope, method) {
var parameters_arr = arguments.slice(2);
var _local2 = function () {
method.apply(scope, arguments.concat(parameters_arr));
};
return(_local2);
}
}
Symbol 283 MovieClip [__Packages.com.lumoslabs.games.DebugOutput] Frame 0
class com.lumoslabs.games.DebugOutput
{
var text;
function DebugOutput (output) {
text = output;
}
}
Symbol 284 MovieClip [__Packages.com.lumoslabs.games.ResetEvent] Frame 0
class com.lumoslabs.games.ResetEvent
{
function ResetEvent () {
}
}
Symbol 285 MovieClip [__Packages.com.lumoslabs.games.GameState] Frame 0
class com.lumoslabs.games.GameState
{
var score, level, isRunning, levelUp, newPoints, trialCount;
function GameState (s, l, r, lu, np, tc) {
score = s;
level = l;
isRunning = r;
levelUp = lu;
newPoints = np;
trialCount = tc;
}
}
Symbol 286 MovieClip [__Packages.com.lumoslabs.games.FinalFinish] Frame 0
class com.lumoslabs.games.FinalFinish
{
function FinalFinish () {
}
}
Symbol 287 MovieClip [__Packages.com.lumoslabs.games.HelpEvent] Frame 0
class com.lumoslabs.games.HelpEvent
{
function HelpEvent () {
}
}
Symbol 288 MovieClip [__Packages.com.lumoslabs.framework.GameRegistrar] Frame 0
class com.lumoslabs.framework.GameRegistrar
{
static var currentManager;
function GameRegistrar () {
}
static function registerGameManager(manager) {
currentManager = manager;
}
static function registerGame(game) {
if (currentManager != undefined) {
currentManager.registerGame(game);
} else {
var _local1 = new com.lumoslabs.framework.ManagedGameAS3Proxy();
if (_local1.useGameManager()) {
_local1.registerGame(game);
} else {
game.start();
}
}
}
static function getGameManager() {
return(currentManager);
}
static function waitingForGameRegistration() {
return(currentManager != undefined);
}
}
Symbol 289 MovieClip [__Packages.com.lumoslabs.framework.ManagedGameAS3Proxy] Frame 0
class com.lumoslabs.framework.ManagedGameAS3Proxy implements com.lumoslabs.framework.GameManager
{
var muteCalled, _game;
function ManagedGameAS3Proxy () {
System.security.allowDomain("*");
muteCalled = false;
_root.flashId = "ManagedGame";
_root.as3Proxy = this;
flx.external.FlashInterface.publish(_root, true);
}
function setResourcePath(resourcePath) {
trace("ManagedGameAS3Proxy, setResourcePath\n");
com.lumoslabs.framework.ResourceHelper.setResourcePath(resourcePath);
}
function useGameManager() {
var _local1 = flx.external.FlashInterface.call(AS2_PROXY_ID + ".useGameManager");
if ((_local1 != null) && (_local1.status == "success")) {
trace("ManagedGameAS3Proxy, FlashInterface manager found");
return(_local1.result);
}
trace("ManagedGameAS3Proxy, no FlashInterface manager found");
return(false);
}
function addSettings(settingsHash) {
trace("ManagedGameAS3Proxy, addSettings");
_game.addSettings(settingsHash);
}
function start() {
_game.start();
if (muteCalled) {
_game.mute();
muteCalled = false;
}
}
function onPauseClick() {
_game.pause();
}
function onHelpClick() {
_game.help();
}
function onMuteClick() {
muteCalled = true;
_game.mute();
}
function registerGame(game) {
trace(("ManagedGameAS3Proxy, registerGame, game: " + game) + newline);
_game = game;
game.registerManager(this);
flx.external.FlashInterface.call(AS2_PROXY_ID + ".registerGame");
}
function getContainerClip() {
return(_root);
}
function onPlay(game) {
flx.external.FlashInterface.call(AS2_PROXY_ID + ".reportPlay");
}
function onData(game, gameData) {
flx.external.FlashInterface.call(AS2_PROXY_ID + ".reportData", gameData);
}
function onReset(game) {
}
function onQuit(game) {
muteCalled = false;
flx.external.FlashInterface.call(AS2_PROXY_ID + ".quit");
flx.external.FlashInterface.call(AS2_PROXY_ID + ".reportQuit");
}
function onPromo(game) {
flx.external.FlashInterface.call(AS2_PROXY_ID + ".reportPromo");
}
function isPausable() {
return(_game.isPausable());
}
function isFullScreen() {
return(_game.isFullScreen());
}
function destroy() {
_game.destroy();
}
static var AS2_PROXY_ID = "root.as2Proxy";
}
Symbol 290 MovieClip [__Packages.flx.external.FlashInterface] Frame 0
class flx.external.FlashInterface extends Object
{
function FlashInterface () {
super();
}
static function addEventListener(event, listener) {
var _local2 = getId(_root);
setup(_local2);
flashIdList[_local2].registry.addEventListener(event, listener);
flash.external.ExternalInterface.call("addAVMListener", __swfID, _local2, event);
}
static function removeEventListener(event, listener) {
var _local2 = getId(_root);
setup(_local2);
flashIdList[_local2].registry.removeEventListener(event, listener);
flash.external.ExternalInterface.call("removeAVMListener", __swfID, _local2, event);
}
static function dispatchEvent(eventObject) {
flash.external.ExternalInterface.call("dispatchAVMEvent", eventObject);
}
static function dispatchHandler(flashId, eventObject) {
flashIdList[flashId].registry.dispatchEvent(eventObject);
}
static function register(id, target, overwrite) {
var _local1 = getId(target);
setup(_local1);
if (overwrite) {
flashIdList[_local1].registry[id] = target;
return(true);
}
if (flashIdList[_local1].registry[id] == null) {
flashIdList[_local1].registry[id] = target;
return(true);
}
return(false);
}
static function unregister(flashId, id) {
setup(flashId);
if (flashIdList[flashId].registry[id]) {
delete flashIdList[flashId].registry[id];
return(true);
}
return(false);
}
static function call(path) {
var _local7 = path.split(".");
var _local6 = _local7.shift().toString();
var _local5;
var _local4;
if (_local6 == "root") {
_local4 = __swfID;
_local5 = __swfID;
} else {
var _local3 = getSWFIds();
for (var _local8 in _local3) {
if (_local3[_local8] == _local6) {
_local4 = __swfID;
_local5 = _local7.shift().toString();
break;
}
}
if ((_local4 == null) || (_local5 == null)) {
_local4 = _local6;
_local5 = _local6;
}
}
path = _local7.join(".");
var _local2 = arguments.slice(1);
for (var _local8 in _local2) {
if (_local2[_local8] == "") {
_local2[_local8] = "$empty";
}
}
return(flash.external.ExternalInterface.call((("getSWF('" + _local4) + "').callFlash_") + _local5, _local4, path, _local2));
}
static function callHandler(flashId, path, args) {
var _local6 = new Object();
_local6.target = target;
_local6.type = type;
_local6.status = "error";
if (!flashIdList[flashId].swf) {
_local6.message = "SWF has not been made public.";
return(_local6);
}
var _local4 = path.split(".");
var target = _local4[0].toString();
var type = _local4.pop().toString();
var _local2 = flashIdList[flashId].registry[target];
if (_local2 == null) {
var _local5 = flashIdList[flashId].swf;
var _local7 = _local4.length;
var _local1 = 0;
while (_local1 < _local7) {
_local5 = _local5[_local4[_local1]];
_local1++;
}
if (_local5 == null) {
_local6.message = "Target does not exist";
alert(1, flashId);
return(_local6);
}
_local2 = _local5;
} else {
_local4.shift();
var _local7 = _local4.length;
var _local1 = 0;
while (_local1 < _local7) {
_local2 = _local2[_local4[_local1]];
_local1++;
}
if (_local2 == null) {
_local6.message = "Target does not exist";
return(_local6);
}
}
for (var _local8 in args) {
if (args[_local8] == "$empty") {
args[_local8] = "";
}
}
if (typeof(_local2[type]) == "function") {
_local6.result = _local2[type].apply(_local2, args);
} else if (args.length < 1) {
_local6.result = _local2[type];
} else {
_local6.result = (_local2[type] = args[0]);
}
_local6.status = "success";
return(_local6);
}
static function alert() {
trace(arguments.join(" : "));
flash.external.ExternalInterface.call("alert", arguments.join(" : "));
}
static function getId(control) {
var _local1 = control;
if (_local1.flashId == null) {
_local1.flashId = __swfID;
if (_local1.flashId == null) {
_local1.flashId = getSWFName(_local1);
}
}
return(_local1.flashId);
}
static function getSWFIds() {
return(Array(flash.external.ExternalInterface.call("getSWFIds")));
}
static function getSWFName(control) {
var _local1 = control._root._url.split("/").join("|").split("\\").join("|").split("|").pop();
if (_local1.indexOf("?") != -1) {
_local1 = _local1.split("?").shift();
}
_local1 = _local1.split(".swf").join("").split("#").shift();
return(unescape(_local1));
}
static function getSWFId() {
var _local2 = "swf" + (Math.random() * 999999);
flash.external.ExternalInterface.addCallback(_local2, null, function () {
});
var _local1 = flash.external.ExternalInterface.call("SWFInfo.locateSWF", _local2);
if (!_local1) {
_local1 = flash.external.ExternalInterface.call("eval", ((((("(window.SWFInfo = {locateSWF:function(swfUID) {var embedtags = document.getElementsByTagName('embed');var objecttags = document.getElementsByTagName('object');var swfobjects = new Array();for(var j=0; j<embedtags.length; j++)swfobjects.push(embedtags[j]);for(var k=0; k<objecttags.length; k++)swfobjects.push(objecttags[k]);for(var i=0; i<swfobjects.length; i++) {var name = swfobjects[i].name ? swfobjects[i].name : swfobjects[i].id;if(document[name] && document[name][swfUID]) {return name;}" + "}") + "return null;") + "}") + "}).locateSWF('") + _local2) + "');");
}
trace("AS2 LOCATION: " + _local1);
trace("AS2 swfUID:: " + _local2);
var _local3 = (_local1 ? (String(_local1)) : null);
return(_local3);
}
static function publish(root, makePublic) {
var _local1 = getId(root);
setup(_local1);
if (makePublic) {
flashIdList[_local1].swf = root;
} else {
delete flashIdList[_local1].swf;
}
}
static function setupEIFunctions() {
if (!staticInit) {
staticInit = true;
if (flash.external.ExternalInterface.call("eval", "$avms")) {
return(undefined);
}
var _local1 = "";
_local1 = _local1 + "function getSWF(swfId)";
_local1 = _local1 + "{";
_local1 = _local1 + "\tif (navigator.appName.indexOf('Microsoft') != -1)";
_local1 = _local1 + "\t\treturn window[swfId];";
_local1 = _local1 + "\treturn document[swfId];";
_local1 = _local1 + "};";
_local1 = _local1 + "function getSWFIds()";
_local1 = _local1 + "{";
_local1 = _local1 + "\tvar list = new Array();";
_local1 = _local1 + "\tvar swfobjects = document.getElementsByTagName('embed');";
_local1 = _local1 + "\tfor(var i=0; i<swfobjects.length; i++)";
_local1 = _local1 + "\t\tlist.push(swfobjects[i].name ? swfobjects[i].name : swfobjects[i].id);";
_local1 = _local1 + "\tswfobjects = document.getElementsByTagName('object');";
_local1 = _local1 + "\tfor(i=0; i<swfobjects.length; i++)";
_local1 = _local1 + "\t\tlist.push(swfobjects[i].name ? swfobjects[i].name : swfobjects[i].id);";
_local1 = _local1 + "\treturn list;";
_local1 = _local1 + "};";
_local1 = _local1 + "var $avms = new Object();";
_local1 = _local1 + "function addAVMListener(swfId, flashId, event)";
_local1 = _local1 + "{";
_local1 = _local1 + "\tif($avms[event] == null)";
_local1 = _local1 + "\t\t$avms[event] = new Object();";
_local1 = _local1 + "\tif($avms[event][swfId] == null)";
_local1 = _local1 + "\t\t$avms[event][swfId] = new Object();";
_local1 = _local1 + "\t$avms[event][swfId][flashId] = event;";
_local1 = _local1 + "};";
_local1 = _local1 + "function removeAVMListener(swfId, flashId, event)";
_local1 = _local1 + "{";
_local1 = _local1 + "\tdelete $avms[event][swfId][flashId];";
_local1 = _local1 + "};";
_local1 = _local1 + "function dispatchAVMEvent(evt)";
_local1 = _local1 + "{";
_local1 = _local1 + "\tvar type = evt.type;";
_local1 = _local1 + "\tvar swfList = $avms[type];";
_local1 = _local1 + "\tfor(var e in swfList)";
_local1 = _local1 + "\t{";
_local1 = _local1 + "\t\tvar flashList = swfList[e];";
_local1 = _local1 + "\t\tfor(var f in flashList)";
_local1 = _local1 + "\t\t{";
_local1 = _local1 + "\t\t\tgetSWF(e)['dispatchFlash_' + f](f, evt);";
_local1 = _local1 + " \t\t}";
_local1 = _local1 + "\t}";
_local1 = _local1 + "};";
flash.external.ExternalInterface.call("eval", _local1);
}
}
static function setup(id) {
setupEIFunctions();
if (id == null) {
return(false);
}
if (flashIdList[id] == null) {
flashIdList[id] = new Object();
flashIdList[id].dispatchHandler = dispatchHandler;
flashIdList[id].callHandler = callHandler;
flashIdList[id].registry = new Object();
mx.events.EventDispatcher.initialize(flashIdList[id].registry);
flash.external.ExternalInterface.addCallback("dispatchFlash_" + id, flashIdList[id], flashIdList[id].dispatchHandler);
flash.external.ExternalInterface.addCallback("callFlash_" + id, flashIdList[id], flashIdList[id].callHandler);
}
return(true);
}
static var flashIdList = new Object();
static var staticInit = false;
static var __swfID = getSWFId();
}
Symbol 291 MovieClip [__Packages.mx.events.EventDispatcher] Frame 0
class mx.events.EventDispatcher
{
function EventDispatcher () {
}
static function _removeEventListener(queue, event, handler) {
if (queue != undefined) {
var _local4 = queue.length;
var _local1;
_local1 = 0;
while (_local1 < _local4) {
var _local2 = queue[_local1];
if (_local2 == handler) {
queue.splice(_local1, 1);
return(undefined);
}
_local1++;
}
}
}
static function initialize(object) {
if (_fEventDispatcher == undefined) {
_fEventDispatcher = new mx.events.EventDispatcher();
}
object.addEventListener = _fEventDispatcher.addEventListener;
object.removeEventListener = _fEventDispatcher.removeEventListener;
object.dispatchEvent = _fEventDispatcher.dispatchEvent;
object.dispatchQueue = _fEventDispatcher.dispatchQueue;
}
function dispatchQueue(queueObj, eventObj) {
var _local7 = "__q_" + eventObj.type;
var _local4 = queueObj[_local7];
if (_local4 != undefined) {
var _local5;
for (_local5 in _local4) {
var _local1 = _local4[_local5];
var _local3 = typeof(_local1);
if ((_local3 == "object") || (_local3 == "movieclip")) {
if (_local1.handleEvent != undefined) {
_local1.handleEvent(eventObj);
}
if (_local1[eventObj.type] != undefined) {
if (exceptions[eventObj.type] == undefined) {
_local1[eventObj.type](eventObj);
}
}
} else {
_local1.apply(queueObj, [eventObj]);
}
}
}
}
function dispatchEvent(eventObj) {
if (eventObj.target == undefined) {
eventObj.target = this;
}
this[eventObj.type + "Handler"](eventObj);
dispatchQueue(this, eventObj);
}
function addEventListener(event, handler) {
var _local3 = "__q_" + event;
if (this[_local3] == undefined) {
this[_local3] = new Array();
}
_global.ASSetPropFlags(this, _local3, 1);
_removeEventListener(this[_local3], event, handler);
this[_local3].push(handler);
}
function removeEventListener(event, handler) {
var _local2 = "__q_" + event;
_removeEventListener(this[_local2], event, handler);
}
static var _fEventDispatcher = undefined;
static var exceptions = {move:1, draw:1, load:1};
}
Symbol 292 MovieClip [__Packages.com.lumoslabs.framework.ResourceHelper] Frame 0
class com.lumoslabs.framework.ResourceHelper
{
static var resourcePath;
function ResourceHelper () {
}
static function pathURL(path) {
return(rootPath() + path);
}
static function setResourcePath(resourcePath) {
com.lumoslabs.framework.ResourceHelper.resourcePath = resourcePath;
}
static function getResourcePath(path) {
if (resourcePath == undefined) {
resourcePath = getDefaultResourcePath();
}
return((resourcePath + "/") + path);
}
static function getDefaultResourcePath() {
var _local1;
if ((System.capabilities.playerType == "External") || (System.capabilities.playerType == "StandAlone")) {
_local1 = "../resources/";
} else {
_local1 = pathURL("flash/resources/");
}
return(_local1);
}
static function rootPath() {
var _local2;
if (System.security.sandboxType == "remote") {
var _local3 = _root._url.indexOf("flash/");
return(_root._url.substr(0, _local3));
}
_local2 = "";
return(_local2);
}
}
Symbol 293 MovieClip [__Packages.com.lumoslabs.games.PlayEvent] Frame 0
class com.lumoslabs.games.PlayEvent
{
function PlayEvent () {
}
}
Symbol 294 MovieClip [__Packages.com.lumoslabs.games.PromoEvent] Frame 0
class com.lumoslabs.games.PromoEvent
{
function PromoEvent () {
}
}
Symbol 295 MovieClip [__Packages.com.lumoslabs.games.nback.NBackContainer] Frame 0
class com.lumoslabs.games.nback.NBackContainer extends com.lumoslabs.games.GameContainer implements com.lumoslabs.util.Observer
{
var width, height, _isPausable, setupContainerClip, model, game, view, container_mc, finish;
function NBackContainer (target, depth, x, y) {
super(target, depth, x, y);
}
function setDefaults() {
width = 640;
height = 480;
_isPausable = true;
}
function initGame(params) {
var _local5 = 2;
var _local2 = 45;
var _local3;
if (params.time != undefined) {
_local2 = Number(params.time);
} else {
trace("NBackContainer, no time passed, default used: " + _local2);
}
if (params.stimulus_type != undefined) {
_local3 = params.stimulus_type;
} else {
trace("NBackContainer, no stimulus_type passed, shapes used");
}
setupContainerClip();
model.clearObservers();
model = new com.lumoslabs.games.nback.NBackGame(_local5, _local2);
game = com.lumoslabs.games.Game(model);
view = new com.lumoslabs.games.nback.NBackView(model, undefined, container_mc, 0, 0, 0, width, height, _local3);
model.addObserver(view);
model.addObserver(this);
}
function destroy() {
view.destroy();
model.clearObservers();
model = null;
view = null;
game = null;
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.FinishEvent) {
gotoResults(com.lumoslabs.games.FinishEvent(infoObj));
} else {
super.update(o, infoObj);
}
}
function gotoResults(info) {
var _local2 = new Object();
_local2.score = info.finalScoresArray[0];
_local2.num_correct = info.numCorrect[0];
_local2.num_tries = info.numTriesArray[0];
_local2.time = info.time;
finish(_local2);
}
static function main() {
var _local2 = new com.lumoslabs.games.nback.NBackContainer(_root, 1, 0, 0);
}
}
Symbol 296 MovieClip [__Packages.com.lumoslabs.games.RaceGame] Frame 0
class com.lumoslabs.games.RaceGame extends com.lumoslabs.games.Game
{
static var stopTime;
var gamesPerSession, time, numTriesArray, numCorrectArray, plPosition, oppPosition, cpuSpeed, pDelta, pause, setChanged, notifyObservers, startTime, intervalID, running, tickInterval, pushFinalScore, updateBestScore, getFinalScoresArray, getBestScore;
function RaceGame (stopTime, gamesPerSession) {
super();
com.lumoslabs.games.RaceGame.stopTime = stopTime;
this.gamesPerSession = gamesPerSession;
time = 0;
numTriesArray = [];
numCorrectArray = [];
plPosition = 0;
oppPosition = 0;
cpuSpeed = 2;
pDelta = 3;
pause = false;
}
function start() {
gameCount = gameCount + 1;
if (gameCount == gamesPerSession) {
endSession = true;
}
setChanged();
notifyObservers(new com.lumoslabs.games.TimeEvent(stopTime));
super.start();
startTime = getTimer();
setChanged();
notifyObservers(new com.lumoslabs.games.DebugOutput("session id is " + _root.session_id));
setChanged();
notifyObservers(new com.lumoslabs.games.PlayEvent());
}
function stop() {
clearTickInterval();
clearInterval(intervalID);
running = false;
}
function run() {
if (running) {
doTurn();
}
}
function doTurn() {
}
function pauseThenFinishTurn() {
intervalID = setInterval(this, "finishTurn", pauseDuration);
}
function finishTurn() {
clearInterval(intervalID);
if (tickInterval == undefined) {
trace("starting clock");
startTime = getTimer();
setTickInterval(1000);
}
run();
}
function doFeedback(correct, bonusUp) {
setChanged();
notifyObservers(new com.lumoslabs.games.FeedbackEvent(0, 0, feedbackDuration, correct, 0, bonusUp));
}
function tick() {
if (!pause) {
time++;
setChanged();
notifyObservers(new com.lumoslabs.games.TimeEvent(stopTime - time));
if (time == stopTime) {
stop();
setChanged();
finish(true);
}
}
}
function finish(playerWon) {
pushFinalScore();
pushNumTries();
pushNumCorrect();
updateBestScore();
stop();
setChanged();
notifyObservers(new com.lumoslabs.games.FinishEvent(getTimer() - startTime, playerWon, getFinalScoresArray(), getBestScore(), endSession, gamesPerSession, numTriesArray, numCorrectArray, afterErrorRight, afterErrorWrong));
}
function reset() {
super.reset();
plPosition = 0;
oppPosition = 0;
time = 0;
afterError = false;
afterErrorRight = 0;
afterErrorWrong = 0;
numTriesArray = [];
numCorrectArray = [];
clearTickInterval();
}
function updateTrialCount(correct, tries) {
numCorrect = correct;
numTries = tries;
}
function pushNumTries() {
numTriesArray.push(numTries);
}
function pushNumCorrect() {
numCorrectArray.push(numCorrect);
}
function getPlayerPosition() {
return(plPosition);
}
function getOpponentPosition() {
return(oppPosition);
}
function getCPUSpeed() {
return(cpuSpeed);
}
function advanceOpp() {
var _local2 = 100 - oppPosition;
if (_local2 > cpuSpeed) {
_local2 = cpuSpeed;
}
if (oppPosition >= 100) {
_local2 = 0;
}
oppPosition = oppPosition + _local2;
setChanged();
notifyObservers(new com.lumoslabs.games.RaceEvent(PLAYER_TWO, _local2 / 100, time));
}
function advancePlayer(delta) {
trace("RACEGAME; advacePlayer()");
var _local3 = plPosition + delta;
if (_local3 > 100) {
delta = 100 - plPosition;
}
if (_local3 < 0) {
delta = 0;
}
plPosition = plPosition + delta;
setChanged();
notifyObservers(new com.lumoslabs.games.RaceEvent(PLAYER_ONE, delta / 100, time));
}
function setTickInterval(period) {
if (tickInterval == undefined) {
tickInterval = setInterval(this, "tick", period);
}
}
function clearTickInterval() {
clearInterval(tickInterval);
tickInterval = undefined;
}
function togglePause() {
pause = !pause;
setChanged();
notifyObservers(new com.lumoslabs.games.PauseEvent());
return(pause);
}
var checktime = 0;
var endSession = false;
var gameCount = 0;
var numTries = 0;
var numCorrect = 0;
var pauseDuration = 200;
var feedbackDuration = 200;
static var PLAYER_ONE = 0;
static var PLAYER_TWO = 1;
var afterError = false;
var afterErrorRight = 0;
var afterErrorWrong = 0;
}
Symbol 297 MovieClip [__Packages.com.lumoslabs.games.TimeEvent] Frame 0
class com.lumoslabs.games.TimeEvent
{
var timeRemaining;
function TimeEvent (timeRemaining) {
this.timeRemaining = timeRemaining;
}
}
Symbol 298 MovieClip [__Packages.com.lumoslabs.games.FeedbackEvent] Frame 0
class com.lumoslabs.games.FeedbackEvent
{
var x, y, duration, isPositive, points, bonusUp;
function FeedbackEvent (x, y, duration, isPositive, points, bonusUp) {
this.x = x;
this.y = y;
this.duration = duration;
this.isPositive = isPositive;
this.points = points;
this.bonusUp = bonusUp;
}
}
Symbol 299 MovieClip [__Packages.com.lumoslabs.games.FinishEvent] Frame 0
class com.lumoslabs.games.FinishEvent
{
var time, playerWon, finalScoresArray, bestScore, endSession, gamesPerSession, numTriesArray, numCorrect, afterErrorRight, afterErrorWrong;
function FinishEvent (time, playerWon, finalScoresArray, bestScore, endSession, gamesPerSession, numTriesArray, numCorrect, afterErrorRight, afterErrorWrong) {
this.time = time;
this.playerWon = playerWon;
this.finalScoresArray = finalScoresArray;
this.bestScore = bestScore;
this.endSession = endSession;
this.gamesPerSession = gamesPerSession;
this.numTriesArray = numTriesArray;
this.numCorrect = numCorrect;
this.afterErrorRight = afterErrorRight;
this.afterErrorWrong = afterErrorWrong;
}
}
Symbol 300 MovieClip [__Packages.com.lumoslabs.games.RaceEvent] Frame 0
class com.lumoslabs.games.RaceEvent
{
var id, delta, time;
function RaceEvent (playerID, delta, time) {
id = playerID;
this.delta = delta;
this.time = time;
}
}
Symbol 301 MovieClip [__Packages.com.lumoslabs.games.PauseEvent] Frame 0
class com.lumoslabs.games.PauseEvent
{
function PauseEvent () {
}
}
Symbol 302 MovieClip [__Packages.com.lumoslabs.games.nback.NBackGame] Frame 0
class com.lumoslabs.games.nback.NBackGame extends com.lumoslabs.games.RaceGame
{
var n, released, stimArray, run, pauseThenFinishTurn, afterError, afterErrorRight, afterErrorWrong, setChanged, notifyObservers, bonusIntervalID, addPoints, updateTrialCount, doFeedback, pause, start;
function NBackGame (n, stopTime) {
super(stopTime, 1);
this.n = n;
released = true;
stimArray = new Array();
}
function keyRelease() {
released = true;
}
function handleKeyResponse(isPositive) {
if (!released) {
return(undefined);
}
released = false;
handleResponse(isPositive);
}
function handleResponse(isPositive) {
if (stimArray.length < n) {
run();
return(undefined);
}
if (waiting == false) {
return(undefined);
}
waiting = false;
if (stimArray.length == 1) {
pauseThenFinishTurn();
return(undefined);
}
numTries = numTries + 1;
var _local2 = false;
var _local3 = false;
if (Number(stimArray[n]) == Number(stimArray[0])) {
_local3 = true;
}
if ((isPositive && (_local3)) || ((!isPositive) && (!_local3))) {
_local2 = true;
consecutiveCorrect++;
if (afterError) {
afterErrorRight++;
afterError = false;
}
} else {
consecutiveCorrect = 0;
if (afterError) {
afterErrorWrong++;
}
afterError = true;
if (bonusTime > 10) {
bonusTime = Math.floor(bonusTime / 2);
} else {
bonusTime = bonusTime - 5;
}
if (bonusTime < 1) {
bonusTime = 0;
bonusCount = 0;
}
setChanged();
notifyObservers(new com.lumoslabs.games.BonusTimeEvent(bonusTime));
}
if (consecutiveCorrect >= bonusThreshold) {
bonusUpFlag = true;
bonusTime = bonusTime + 5;
consecutiveCorrect = 0;
if (bonusCount < 3) {
bonusCount = bonusCount + 1;
}
setChanged();
notifyObservers(new com.lumoslabs.games.BonusTimeEvent(bonusTime));
}
if (bonusTime > 0) {
bonusFlag = true;
if (bonusIntervalID == null) {
bonusIntervalID = setInterval(this, "bonusLeak", 1000);
}
} else {
bonusFlag = false;
bonusCount = 0;
}
if (_local2 && (bonusFlag)) {
addPoints((SCORE_INCREMENT * bonusCount) * (bonusCount + 2));
numCorrect = numCorrect + 1;
} else if (_local2) {
addPoints(SCORE_INCREMENT);
numCorrect = numCorrect + 1;
}
setChanged();
notifyObservers(new com.lumoslabs.games.BonusEvent(bonusFlag, false, bonusFactor, 0));
updateTrialCount(numCorrect, numTries);
if (stimArray.length > n) {
doFeedback(_local2, bonusUpFlag);
}
bonusUpFlag = false;
pauseThenFinishTurn();
}
function bonusLeak() {
if (!pause) {
if (bonusTime > 0) {
bonusTime = bonusTime - 1;
} else {
bonusCount = 0;
clearInterval(bonusIntervalID);
bonusIntervalID = null;
setChanged();
notifyObservers(new com.lumoslabs.games.BonusEvent(false));
}
setChanged();
notifyObservers(new com.lumoslabs.games.BonusTimeEvent(bonusTime));
}
}
function handleMiscResponse(keyCode) {
if (stimArray.length < n) {
run();
}
}
function doTurn() {
var _local2 = random(stimCount);
var _local3 = random(2);
var _local4 = false;
if (stimArray.length > n) {
stimArray.shift();
if (_local3 == 1) {
_local2 = stimArray[0];
} else if (_local3 == 0) {
while (_local2 == stimArray[0]) {
_local2 = random(stimCount);
}
}
}
stimArray.push(_local2);
setChanged();
notifyObservers(new com.lumoslabs.games.nback.NEvent(_local2, n));
waiting = true;
if ((n > 1) && (stimArray.length < (n + 1))) {
doTurn();
}
}
function getStimCount() {
return(stimCount);
}
function getN() {
return(n);
}
function reset() {
super.reset();
stimArray = new Array();
waiting = false;
numCorrect = 0;
numTries = 0;
consecutiveCorrect = 0;
bonusFlag = false;
bonusUpFlag = false;
bonusTime = 0;
bonusCount = 0;
}
function help() {
setChanged();
notifyObservers(new com.lumoslabs.games.HelpEvent());
reset();
}
function endHelp() {
reset();
start();
}
function toggleMute() {
mute = !mute;
setChanged();
notifyObservers(new com.lumoslabs.games.MuteEvent(mute));
return(mute);
}
function promo() {
setChanged();
notifyObservers(new com.lumoslabs.games.PromoEvent());
}
var stimCount = 3;
var numTries = 0;
var numCorrect = 0;
var waiting = false;
var SCORE_INCREMENT = 10;
var SCORE_DECREMENT = -10;
var bonusFlag = false;
var bonusUpFlag = false;
var bonusThreshold = 5;
var bonusFactor = 3;
var doubleBonusFactor = 10;
var bonusDuration = 5000;
var consecutiveCorrect = 0;
var bonusTime = 0;
var bonusCount = 0;
var mute = false;
}
Symbol 303 MovieClip [__Packages.com.lumoslabs.games.BonusTimeEvent] Frame 0
class com.lumoslabs.games.BonusTimeEvent
{
var bonusTime;
function BonusTimeEvent (bonusTime) {
this.bonusTime = bonusTime;
}
}
Symbol 304 MovieClip [__Packages.com.lumoslabs.games.BonusEvent] Frame 0
class com.lumoslabs.games.BonusEvent
{
var bonusFlag, doubleBonusFlag, bonusFactor, doubleBonusFactor, bonusTime;
function BonusEvent (bonusFlag, doubleBonusFlag, bonusFactor, doubleBonusFactor, bonusTime) {
this.bonusFlag = bonusFlag;
this.doubleBonusFlag = doubleBonusFlag;
this.bonusFactor = bonusFactor;
this.doubleBonusFactor = doubleBonusFactor;
this.bonusTime = bonusTime;
}
}
Symbol 305 MovieClip [__Packages.com.lumoslabs.games.nback.NEvent] Frame 0
class com.lumoslabs.games.nback.NEvent
{
var id, numBack;
function NEvent (stimID, n) {
id = stimID;
numBack = n;
}
}
Symbol 306 MovieClip [__Packages.com.lumoslabs.games.MuteEvent] Frame 0
class com.lumoslabs.games.MuteEvent
{
var mute;
function MuteEvent (mute) {
this.mute = mute;
}
}
Symbol 307 MovieClip [__Packages.com.lumoslabs.util.View] Frame 0
interface com.lumoslabs.util.View
{
}
Symbol 308 MovieClip [__Packages.com.lumoslabs.util.Controller] Frame 0
interface com.lumoslabs.util.Controller
{
}
Symbol 309 MovieClip [__Packages.com.lumoslabs.util.AbstractView] Frame 0
class com.lumoslabs.util.AbstractView implements com.lumoslabs.util.Observer, com.lumoslabs.util.View
{
var model, controller;
function AbstractView (m, c) {
setModel(m);
if (!(c === undefined)) {
setController(c);
}
}
function defaultController(model) {
return(null);
}
function setModel(m) {
model = m;
}
function getModel() {
return(model);
}
function setController(c) {
controller = c;
getController().setView(this);
}
function getController() {
if (controller === undefined) {
setController(defaultController(getModel()));
}
return(controller);
}
function update(o, infoObj) {
}
}
Symbol 310 MovieClip [__Packages.com.lumoslabs.games.GameView] Frame 0
class com.lumoslabs.games.GameView extends com.lumoslabs.util.AbstractView
{
var width, height, game_mc, statusBar, soundEffects, help_mc, mouseView_mc;
function GameView (gameModel, controller, target, depth, x, y, width, height) {
super(gameModel, controller);
this.width = width;
this.height = height;
buildGameView(target, depth, x, y, width, height);
initMouse();
initKeys();
}
function buildGameView(target, depth, x, y, width, height) {
game_mc = target.createEmptyMovieClip("game_mc", depth);
game_mc._x = x;
game_mc._y = y;
statusBar = new com.lumoslabs.games.StatusBar(game_mc, game_mc.getNextHighestDepth() + 1, com.lumoslabs.games.StatusBar.TOP_RIGHT);
}
function defaultController(model) {
return(new com.lumoslabs.games.GameController(model, this));
}
function getSounds() {
return(soundEffects);
}
function getMovieClip() {
return(game_mc);
}
function getStatusBar() {
return(statusBar);
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.MuteEvent) {
soundEffects.setMute(com.lumoslabs.games.MuteEvent(infoObj).mute);
} else if (infoObj instanceof com.lumoslabs.games.HelpEvent) {
showDemo();
} else if (infoObj instanceof com.lumoslabs.games.GameState) {
var _local2 = com.lumoslabs.games.GameState(infoObj);
if (!_local2.isRunning) {
revertMouse();
} else {
transformMouse();
trace("GameView, update, state.score: " + _local2.score);
statusBar.setScore(_local2.score);
statusBar.showTrialCount(_local2.trialCount);
if (_local2.levelUp) {
levelUp(_local2.level);
}
}
}
}
function showDemo() {
game_mc._visible = false;
soundEffects.stopAllSounds();
help_mc.showDemo();
}
function endDemo() {
game_mc._visible = true;
}
function initMouse() {
}
function initKeys() {
}
function transformMouse() {
Mouse.hide();
mouseView_mc._visible = true;
}
function revertMouse() {
Mouse.show();
mouseView_mc._visible = false;
}
function moveMouse(x, y) {
mouseView_mc._x = x;
mouseView_mc._y = y;
updateAfterEvent();
}
function levelUp(level) {
trace("NEW LEVEL found in GameView: " + level);
}
var mouseDepth = 1000;
}
Symbol 311 MovieClip [__Packages.com.lumoslabs.games.StatusBar] Frame 0
class com.lumoslabs.games.StatusBar
{
var position, status_mc, level_txt, textFormat, score_txt, trialCount_txt;
function StatusBar (target, depth, position) {
initTextFormat();
buildStatusBar(target, depth);
this.position = position;
var _local3 = status_mc._width + 5;
var _local4 = level_txt.textHeight + 5;
switch (position) {
case TOP_RIGHT :
status_mc._x = (Stage.width - (_local3 / 2)) + 10;
status_mc._y = 5;
break;
case TOP_LEFT :
status_mc._x = 0;
status_mc._y = 0;
break;
case BOTTOM_RIGHT :
status_mc._x = target._width - _local3;
status_mc._y = target._height - _local4;
break;
case BOTTOM_LEFT :
status_mc._x = 0;
status_mc._y = target._height - _local4;
break;
default :
status_mc._x = target._width - _local3;
status_mc._y = 0;
}
}
function buildStatusBar(target, depth) {
target.attachMovie("status_mc", "status_mc", depth);
status_mc = target.status_mc;
status_mc._x = Stage.width;
status_mc._y = 0;
setScore(0);
showTrialCount(0);
}
function setScore(newScore) {
status_mc.point_txt.text = String(newScore);
}
function showTrialCount(trialCount) {
status_mc.exposure_txt.text = String(trialCount);
}
function setTextFormat(newTextFormat) {
textFormat = newTextFormat;
level_txt.setNewTextFormat(textFormat);
score_txt.setNewTextFormat(textFormat);
trialCount_txt.setNewTextFormat(textFormat);
}
function initTextFormat() {
textFormat = new TextFormat();
textFormat.bold = true;
textFormat.font = "Arial";
textFormat.size = 20;
}
function showPoints(show) {
status_mc.point_txt._visible = show;
status_mc.points_mc._visible = show;
}
static var TOP_LEFT = 0;
static var TOP_RIGHT = 1;
static var BOTTOM_RIGHT = 2;
static var BOTTOM_LEFT = 3;
}
Symbol 312 MovieClip [__Packages.com.lumoslabs.util.AbstractController] Frame 0
class com.lumoslabs.util.AbstractController implements com.lumoslabs.util.Controller
{
var model, view;
function AbstractController (m) {
setModel(m);
}
function setModel(m) {
model = m;
}
function getModel() {
return(model);
}
function setView(v) {
view = v;
}
function getView() {
return(view);
}
}
Symbol 313 MovieClip [__Packages.com.lumoslabs.games.GameController] Frame 0
class com.lumoslabs.games.GameController extends com.lumoslabs.util.AbstractController
{
var gameView, getModel;
function GameController (gameModel, gameView) {
super(gameModel);
this.gameView = gameView;
}
function onMouseDown() {
var _local3 = com.lumoslabs.games.Game(getModel());
if (_local3.isRunning()) {
_local3.onClick(_root._xmouse, _root._ymouse);
}
}
function onMouseMove() {
gameView.moveMouse(_root._xmouse, _root._ymouse);
}
function helpClick() {
com.lumoslabs.games.Game(getModel()).help();
}
function startClick(difficulty) {
trace("GameController, startClick, difficulty: " + difficulty);
com.lumoslabs.games.Game(getModel()).start(difficulty);
com.lumoslabs.games.birdwatching.BirdWatchingGame(getModel()).setDifficulty(difficulty);
}
function doneClick() {
com.lumoslabs.games.Game(getModel()).finalFinish();
}
function restartClick() {
var _local2 = com.lumoslabs.games.Game(getModel());
_local2.restart();
}
function letterClick(letter) {
com.lumoslabs.games.birdwatching.BirdWatchingGame(getModel()).handleLetterPick(letter);
com.lumoslabs.games.birdwatching.BirdWatchingView(gameView).hideInstructions();
}
function nextClick() {
if (gameView instanceof com.lumoslabs.games.birdwatching.BirdWatchingView) {
com.lumoslabs.games.birdwatching.BirdWatchingView(gameView).clearLetterScreen();
com.lumoslabs.games.birdwatching.BirdWatchingView(gameView).updateLevel();
} else if (gameView instanceof com.lumoslabs.games.birdwatching.BirdWatchingTestView) {
com.lumoslabs.games.birdwatching.BirdWatchingTestView(gameView).clearLetterScreen();
}
com.lumoslabs.games.birdwatching.BirdWatchingGame(getModel()).doNextTrial();
}
function submitGuessClick(answer) {
com.lumoslabs.games.birdwatching.BirdWatchingGame(getModel()).handleWordGuess(answer);
}
}
Symbol 314 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdWatchingSounds] Frame 0
class com.lumoslabs.games.birdwatching.BirdWatchingSounds extends com.lumoslabs.games.SoundEffects
{
var target_mc, setAmbientSound, addSound, shutterSound, badLetterGuess, badWordGuess, goodLetterGuess, goodWordGuess, setPositiveFeedbackSound, setNegativeFeedbackSound, feedbackDelay, stimulusLevel, stimulusSound, feedbackInterval, positiveFeedback, negativeFeedback;
function BirdWatchingSounds (target) {
super(target);
target_mc = target;
attachSounds();
setAmbientSound(addSound("BW - Ambience.wav"));
}
function attachSounds() {
shutterSound = addSound("BW - Camera Click.wav");
badLetterGuess = addSound("missedLetter.wav");
badWordGuess = addSound("missedWord.wav");
goodLetterGuess = addSound("BW - Xylophone.mp3");
goodWordGuess = addSound("BW - Applause.mp3");
setPositiveFeedbackSound(addSound("BW - Ding.mp3"));
setNegativeFeedbackSound(addSound("wrong.mp3"));
feedbackDelay = shutterSound.duration + 300;
}
function playStimulusSound(level) {
if (stimulusLevel != level) {
stimulusLevel = level;
stimulusSound = addSound(("BW - " + level) + ".wav");
}
stimulusSound.start(0, 1);
}
function playShutterSound() {
shutterSound.start(0, 1);
}
function feedbackSound(isPositive) {
feedbackInterval = setInterval(this, "playNow", feedbackDelay, isPositive);
}
function playNow(isPositive) {
clearInterval(feedbackInterval);
if (isPositive) {
positiveFeedback.start(0, 1);
} else {
negativeFeedback.start(0, 1);
}
}
function badLetterGuessSound() {
badLetterGuess.start();
}
function badWordGuessSound() {
badWordGuess.start();
}
function goodLetterGuessSound() {
goodLetterGuess.start();
}
function goodWordGuessSound() {
goodWordGuess.start();
}
}
Symbol 315 MovieClip [__Packages.com.lumoslabs.games.StimulusResponseGame] Frame 0
class com.lumoslabs.games.StimulusResponseGame extends com.lumoslabs.games.Game
{
var setChanged, notifyObservers, waitForResponse, runIntervalID, waitIntervalID, fireTime, responseTime, intervalID;
function StimulusResponseGame (target, depth, x, y) {
super(target, depth, x, y);
}
function start() {
super.start();
setChanged();
notifyObservers(new com.lumoslabs.games.PlayEvent());
}
function isWaiting() {
return(waitForResponse);
}
function doTurn() {
clearInterval(runIntervalID);
waitIntervalID = setInterval(this, "gotNoResponse", waitMax);
fireStimulus();
fireTime = getTimer();
}
function fireStimulus() {
}
function onClick(x, y) {
if (waitForResponse) {
gotResponse(x, y);
}
}
function gotResponse(x, y) {
clearInterval(waitIntervalID);
waitForResponse = false;
responseTime = getTimer() - fireTime;
handleResponse(x, y);
}
function handleResponse(x, y) {
}
function handleNoResponse() {
}
function run() {
clearInterval(intervalID);
if (runIntervalID != null) {
clearInterval(runIntervalID);
}
var _local2 = delayTime + Math.floor(Math.random() * randomMax);
runIntervalID = setInterval(this, "doTurn", _local2);
}
function gotNoResponse() {
clearInterval(waitIntervalID);
waitForResponse = false;
handleNoResponse();
}
function reset() {
super.reset();
clearInterval(waitIntervalID);
clearInterval(runIntervalID);
waitForResponse = false;
}
static var delayTime = 1000;
static var randomMax = 1000;
static var waitMax = 10000;
static var feedbackDuration = 2000;
}
Symbol 316 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdWatchingGame] Frame 0
class com.lumoslabs.games.birdwatching.BirdWatchingGame extends com.lumoslabs.games.StimulusResponseGame
{
var setLevel, difficultyLevel, initialDifficultyLevel, maxDistance, initialTrialNumberLimit, trialNumberLimit, setTrialsRemaining, evaluate, calibrate, birdManager, currentBird, setChanged, notifyObservers, waitForResponse, gotResponse, positiveResponse, pointsMultiplier, addPoints, difficulty, trialsRemaining, bestStimulusDuration, levelUp, guessPenalty, bonusFactor, pointsPerLetter, run, score, scoreThreshold, stimulusX, stimulusY, rMax, numberDistractors, beginWaitForResponseID, running, changed, reset;
function BirdWatchingGame (trialNumberLimit, maxDistance, difficultyLevel, evaluate, calibrate) {
super();
setLevel(0);
this.difficultyLevel = difficultyLevel;
initialDifficultyLevel = difficultyLevel;
this.maxDistance = maxDistance;
initialTrialNumberLimit = trialNumberLimit;
if (calibrate) {
this.trialNumberLimit = CALIBRATE_TRIAL_NUMBER_LIMIT;
} else {
this.trialNumberLimit = trialNumberLimit;
}
setTrialsRemaining(trialNumberLimit);
this.evaluate = evaluate;
this.calibrate = calibrate;
if (difficultyLevel <= easyNameLevelMax) {
birdManager = new com.lumoslabs.games.birdwatching.BirdManager(com.lumoslabs.framework.ResourceHelper.getResourcePath(EASY_NAME_FILE));
} else {
birdManager = new com.lumoslabs.games.birdwatching.BirdManager(com.lumoslabs.framework.ResourceHelper.getResourcePath(HARD_NAME_FILE));
}
}
function start(difficulty) {
resetProperties();
currentBird = birdManager.getNextBird();
setChanged();
notifyObservers(new com.lumoslabs.games.birdwatching.StartEvent(currentBird.getName()));
super.start();
}
function onClick(x, y) {
if (waitForResponse) {
setChanged();
notifyObservers(new com.lumoslabs.games.ResponseSoundEvent());
setTrialsRemaining(trialNumberLimit - trialCount);
gotResponse(x, y);
}
}
function handleResponse(x, y) {
super.handleResponse(x, y);
positiveResponse = false;
var _local3;
var _local6 = Math.floor(calculateDistance(x, y));
if (_local6 <= maxDistance) {
positiveResponse = true;
_local3 = ((maxDistance - _local6) + 1) * pointsMultiplier;
addPoints(_local3);
positiveDistanceArray.push(Math.round(calculateDistance(x, y) * 10) / 10);
} else {
positiveResponse = false;
}
if (evaluate) {
if (positiveResponse) {
setDifficulty(difficulty + 1);
} else {
setDifficulty(difficulty - 2);
}
}
errorDistanceArray.push(Math.round(calculateDistance(x, y) * 10) / 10);
responseCount++;
if (!positiveResponse) {
letterResponseArray.push("No_letter");
}
setChanged();
notifyObservers(new com.lumoslabs.games.FeedbackEvent(x, y, feedbackDuration, positiveResponse, _local3));
setChanged();
if (positiveResponse) {
notifyObservers(new com.lumoslabs.games.birdwatching.LetterEvent(birdManager.getLetterList(), trialsRemaining));
} else if ((!positiveResponse) && (trialsRemaining > 0)) {
notifyObservers(new com.lumoslabs.games.BadInputEvent());
} else {
notifyObservers(new com.lumoslabs.games.LastTrialEvent());
}
}
function handleNoResponse() {
setTrialsRemaining(trialNumberLimit - trialCount);
setChanged();
notifyObservers(new com.lumoslabs.games.BadInputEvent());
errorDistanceArray.push(0.001);
letterResponseArray.push("No_response");
if (calibrate) {
stimulusDuration = stimulusDuration * calibrateZestDown;
stimulusDuration = Math.max(stimulusDuration, calibrateMaxStimDur);
}
}
function handleLetterPick(letter) {
var _local3 = currentBird.getCurrentLetter();
if (letter == _local3) {
gotLetter = true;
currentBird.setCaptured();
if (calibrate) {
if (positiveResponse) {
bestStimulusDuration = stimulusDuration;
stimulusDuration = stimulusDuration * calibrateZestUp;
} else {
stimulusDuration = stimulusDuration * calibrateZestDown;
stimulusDuration = Math.max(stimulusDuration, calibrateMaxStimDur);
}
}
}
if (currentBird.isCaptured()) {
addPoints(getWordPoints(currentBird));
levelUp();
birdManager.captureCurrentBird();
}
var _local2 = currentBird;
if (currentBird.isCaptured()) {
currentBird = birdManager.getNextBird();
}
setChanged();
notifyObservers(new com.lumoslabs.games.birdwatching.BirdCaptureEvent(letter, _local2.getName(), currentBird.getName(), gotLetter, _local2.isCaptured(), getWordPoints(_local2), getBonusPoints(_local2), trialNumberLimit - trialCount));
if (gotLetter) {
letterResponseArray.push("correct");
} else {
letterResponseArray.push("wrong");
}
}
function handleWordGuess(answer) {
if (answer.toUpperCase() == currentBird.getName()) {
currentBird.setCaptured(true);
levelUp();
addPoints(getWordPoints(currentBird) + getBonusPoints(currentBird));
birdManager.captureCurrentBird();
} else {
currentBird.setCaptured(false);
addPoints(guessPenalty);
setChanged();
notifyObservers(new com.lumoslabs.games.BadGuessEvent(guessPenalty));
}
var _local2 = currentBird;
if (currentBird.isCaptured()) {
currentBird = birdManager.getNextBird();
}
setChanged();
notifyObservers(new com.lumoslabs.games.birdwatching.BirdCaptureEvent(null, _local2.getName(), currentBird.getName(), gotLetter, _local2.isCaptured(), getWordPoints(_local2), getBonusPoints(_local2), trialNumberLimit - trialCount));
}
function getBonusPoints(bird) {
return(bonusFactor * bird.getNumberOfUnusedLetters());
}
function getWordPoints(bird) {
return(pointsPerLetter * bird.getName().length);
}
function doNextTrial() {
if (((trialNumberLimit == 0) || (trialNumberLimit == null)) || (trialCount < trialNumberLimit)) {
run();
} else {
var _local2 = getMedianError(errorDistanceArray);
setChanged();
updateUserLevel(_local2);
if (currentBird.isCurrent()) {
notifyObservers(new com.lumoslabs.games.birdwatching.SessionInfo(eccentricityArray, errorDistanceArray, _local2, letterResponseArray, birdManager.getCapturedBirdCount(), true, responseCount, score, difficulty, difficultyLevel, userLevelUp, userLevelDown, scoreThreshold, positiveDistanceArray, currentBird.getName()));
} else {
notifyObservers(new com.lumoslabs.games.birdwatching.SessionInfo(eccentricityArray, errorDistanceArray, _local2, letterResponseArray, birdManager.getCapturedBirdCount(), true, responseCount, score, difficulty, difficultyLevel, userLevelUp, userLevelDown, scoreThreshold, positiveDistanceArray));
}
calibrate = false;
initialDifficultyLevel = difficultyLevel;
trialNumberLimit = initialTrialNumberLimit;
}
}
static function getMedianError(distanceArray) {
if (distanceArray.length > 0) {
var _local1 = distanceArray.slice();
_local1.sort(Array.NUMERIC);
return(_local1[Math.floor(_local1.length / 2)]);
}
return(0);
}
function calculateDistance(x, y) {
var _local3 = stimulusX;
var _local2 = stimulusY;
return(Math.sqrt(Math.pow(x - _local3, 2) + Math.pow(y - _local2, 2)));
}
function fireStimulus() {
trialCount = trialCount + 1;
var _local3;
if (gotLetter) {
_local3 = currentBird.getNextLetter();
} else {
_local3 = currentBird.getAnotherLetter();
}
var _local2 = new com.lumoslabs.games.birdwatching.StimulusCoordinates(rMin, rMax, Stage.width, Stage.height);
stimulusX = _local2.getStimulusX();
stimulusY = _local2.getStimulusY();
eccentricityArray.push(Math.round(_local2.getRadius()));
setChanged();
notifyObservers(new com.lumoslabs.games.birdwatching.StimulusEvent(stimulusX, stimulusY, stimulusDuration, useCentralStim, _local3, rMin, rMax, numberDistractors, difficulty, trialCount));
gotLetter = false;
beginWaitForResponseID = setInterval(this, "beginWaiting", stimulusDuration);
}
function beginWaiting() {
waitForResponse = true;
clearInterval(beginWaitForResponseID);
}
function setDifficulty(difficulty) {
if (difficulty < 1) {
difficulty = 1;
}
if (difficulty > 10) {
difficulty = 10;
}
this.difficulty = difficulty;
if (difficulty == 1) {
numberDistractors = 0;
stimulusDuration = 400;
feedbackDuration = 2000;
rMax = 300;
} else if (difficulty == 2) {
numberDistractors = 0;
stimulusDuration = 250;
feedbackDuration = 1500;
rMax = 400;
} else if (difficulty == 3) {
numberDistractors = 0;
stimulusDuration = 175;
rMax = 500;
} else if (difficulty == 4) {
numberDistractors = 0;
stimulusDuration = 100;
rMax = 600;
} else if (difficulty == 5) {
numberDistractors = 3;
stimulusDuration = 175;
} else if (difficulty == 6) {
numberDistractors = 3;
stimulusDuration = 150;
} else if (difficulty == 7) {
numberDistractors = 5;
stimulusDuration = 125;
rMin = 200;
} else if (difficulty == 8) {
numberDistractors = 9;
stimulusDuration = 100;
rMin = 200;
} else if (difficulty == 9) {
numberDistractors = 12;
stimulusDuration = 75;
rMin = 250;
} else if (difficulty == 10) {
numberDistractors = 15;
stimulusDuration = 40;
rMin = 250;
}
pointsMultiplier = Math.round((difficulty * difficulty) / 2);
if (evaluate || (calibrate)) {
guessPenalty = -20;
bonusFactor = 12;
pointsPerLetter = 9;
} else {
guessPenalty = -5 * pointsMultiplier;
bonusFactor = 3 * pointsMultiplier;
pointsPerLetter = pointsMultiplier;
}
if (calibrate) {
numberDistractors = 0;
stimulusDuration = calibrateMaxStimDur;
bestStimulusDuration = calibrateMaxStimDur;
feedbackDuration = 1500;
rMax = undefined;
}
}
function updateUserLevel(medianError) {
if (calibrate) {
var _local4 = [400, 250, 175, 100, 75, 40];
var _local2;
var _local3 = true;
_local2 = 0;
while (_local3 && (_local2 < _local4.length)) {
_local3 = bestStimulusDuration < _local4[_local2];
_local2++;
}
difficultyLevel = _local2;
} else {
var _local5 = 17;
scoreThreshold = (trialNumberLimit * pointsMultiplier) * (maxDistance - _local5);
scoreThreshold = 100 * Math.round(scoreThreshold / 100);
if (difficultyLevel != difficulty) {
return(undefined);
}
if (score > scoreThreshold) {
difficultyLevel = difficultyLevel + 1;
userLevelUp = true;
}
difficultyLevel = Math.min(10, Math.max(difficultyLevel, 1));
}
}
function getAverageError(distanceArray) {
var _local4 = 0;
var _local3 = 0;
var _local1 = 0;
while (_local1 < distanceArray.length) {
_local3 = _local3 + distanceArray[_local1];
_local1++;
}
_local4 = _local3 / distanceArray.length;
return(_local4);
}
function resetProperties() {
gotLetter = false;
letterCount = 0;
trialCount = 0;
setTrialsRemaining(trialNumberLimit - trialCount);
responseCount = 0;
delete birdManager;
if (difficultyLevel <= easyNameLevelMax) {
birdManager = new com.lumoslabs.games.birdwatching.BirdManager(com.lumoslabs.framework.ResourceHelper.getResourcePath(EASY_NAME_FILE));
} else {
birdManager = new com.lumoslabs.games.birdwatching.BirdManager(com.lumoslabs.framework.ResourceHelper.getResourcePath(HARD_NAME_FILE));
}
currentBird = null;
running = false;
userLevelUp = false;
userLevelDown = false;
pointsMultiplier = undefined;
errorDistanceArray = new Array();
eccentricityArray = new Array();
letterResponseArray = new Array();
positiveDistanceArray = new Array();
}
function restart() {
changed = false;
rMin = 120;
stimulusDuration = 100;
feedbackDuration = 1000;
setLevel(0);
difficultyLevel = initialDifficultyLevel;
resetProperties();
reset();
}
function toggleMute() {
mute = !mute;
setChanged();
notifyObservers(new com.lumoslabs.games.MuteEvent(mute));
return(mute);
}
function help() {
restart();
setChanged();
notifyObservers(new com.lumoslabs.games.HelpEvent());
}
static var calibrateZestUp = 0.7;
static var calibrateZestDown = 1.2;
static var calibrateMaxStimDur = 1000;
var userLevelUp = false;
var userLevelDown = false;
var numberOfLevels = 10;
var rMin = 120;
var stimulusDuration = 100;
var feedbackDuration = 1000;
var stimulusWidth = 60;
var stimulusHeight = 50;
var gotLetter = false;
var useCentralStim = true;
var letterCount = 0;
static var CALIBRATE_TRIAL_NUMBER_LIMIT = 10;
static var EASY_NAME_FILE = "bird_watching/birdnames_easy.txt";
static var HARD_NAME_FILE = "bird_watching/birdnames_hard.txt";
static var easyNameLevelMax = 5;
var errorDistanceArray = new Array();
var positiveDistanceArray = new Array();
var eccentricityArray = new Array();
var letterResponseArray = new Array();
var trialCount = 0;
var responseCount = 0;
var mute = false;
}
Symbol 317 MovieClip [__Packages.com.lumoslabs.games.birdwatching.Bird] Frame 0
class com.lumoslabs.games.birdwatching.Bird
{
var name, letterCount, letters, usedLetters, accessCount, captured, current;
function Bird (name) {
this.name = name.toUpperCase();
var _local2;
_local2 = getUCharArray(this.name);
letterCount = _local2.length;
letters = new com.lumoslabs.util.RandomList(_local2);
usedLetters = new Array();
accessCount = 0;
captured = false;
current = false;
}
function getAccessCount() {
return(accessCount);
}
function getName() {
return(name);
}
function getNextLetter() {
if (letters.length == 0) {
return(null);
}
var _local2 = String(letters.grab());
var _local3 = usedLetters.push(_local2);
accessCount++;
current = true;
return(_local2);
}
function getCurrentLetter() {
if (usedLetters.length == 0) {
return(getNextLetter());
}
return(usedLetters[usedLetters.length - 1]);
}
function getAnotherLetter() {
if (usedLetters.length > 0) {
letters.put(usedLetters.pop());
}
accessCount++;
return(getNextLetter());
}
function isCaptured() {
return(captured);
}
function isCurrent() {
return(current);
}
function setCaptured(captured) {
this.captured = captured;
if (letters.length == 0) {
this.captured = true;
}
return(captured);
}
function equals(birdName) {
if (birdName.toUpperCase() == name) {
return(true);
}
return(false);
}
function getNumberOfUnusedLetters() {
return(letters.length);
}
static function getUCharArray(string) {
var _local1 = new Array();
getUChar(string, _local1);
return(_local1);
}
static function getUChar(string, charArray) {
if (string.length == 0) {
return(undefined);
}
var _local1;
var _local3;
var _local5 = 0;
_local1 = string.charAt(0);
charArray.push(_local1);
_local3 = string.split(_local1);
getUChar(_local3.join(""), charArray);
}
}
Symbol 318 MovieClip [__Packages.com.lumoslabs.util.RandomList] Frame 0
class com.lumoslabs.util.RandomList
{
var anchor;
function RandomList (elementsArray) {
var _local2;
_local2 = 0;
while (_local2 < elementsArray.length) {
put(elementsArray[_local2]);
_local2++;
}
}
function put(object) {
var _local2 = new Object();
_local2.next = anchor;
_local2.data = object;
anchor = _local2;
length++;
}
function grab() {
var _local2;
var _local5;
var _local4 = random(length);
var _local3 = 1;
_local2 = anchor;
if (_local4 == 0) {
_local5 = anchor.data;
anchor = anchor.next;
length--;
return(_local5);
}
while (_local3 < _local4) {
_local2 = _local2.next;
_local3++;
}
_local5 = _local2.next.data;
_local2.next = _local2.next.next;
length--;
return(_local5);
}
function dump() {
var _local2;
var _local3 = 0;
_local2 = anchor;
while (_local3 < length) {
trace(_local2.data.toString());
_local2 = _local2.next;
_local3++;
}
}
function size() {
return(length);
}
var length = 0;
}
Symbol 319 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdManager] Frame 0
class com.lumoslabs.games.birdwatching.BirdManager extends LoadVars
{
var defaultList, load, capturedBirds, currentBird, birdNames, birds;
function BirdManager (nameFile) {
super();
defaultList = new com.lumoslabs.util.RandomList(defaultNames);
load(nameFile);
}
function captureCurrentBird() {
capturedBirds.push(currentBird);
capturedBirdCount = capturedBirdCount + 1;
}
function getCurrentBird() {
return(currentBird);
}
function getNextBird() {
var _local2 = String(birdNames.grab());
if (_local2 == "undefined") {
trace("Still loading bird name file - default name will be used");
currentBird = new com.lumoslabs.games.birdwatching.Bird(String(defaultList.grab()));
} else {
currentBird = new com.lumoslabs.games.birdwatching.Bird(_local2);
}
return(currentBird);
}
function getLetterList(letterCount) {
if (letterCount == null) {
letterCount = 5;
}
var _local3 = new Array(5);
var _local5 = currentBird.getCurrentLetter().toUpperCase();
_local3[random(5)] = _local5;
var _local4 = getRandomAlphabet(_local5);
var _local2 = 0;
while (_local2 < 5) {
if (_local3[_local2] == null) {
_local3[_local2] = _local4.grab();
}
_local2++;
}
return(_local3);
}
function getCapturedBirdCount() {
return(capturedBirdCount);
}
function onLoad(success) {
doneLoading = true;
if (success) {
birdNames = new com.lumoslabs.util.RandomList(birds.split(NAME_DELIMITER));
} else {
trace("Problem loading bird name file - only default names will be used");
birdNames = defaultList;
}
trace(("there are " + birdNames.size()) + " birds.");
}
function getRandomAlphabet(noChar) {
var _local4 = new com.lumoslabs.util.RandomList();
var _local3;
var _local2 = 0;
while (_local2 < 26) {
_local3 = String.fromCharCode(CHAR_START + _local2);
if (_local3 != noChar) {
_local4.put(_local3);
}
_local2++;
}
return(_local4);
}
static var defaultNames = ["albatross", "avocet", "bittern", "blackbird", "bluejay", "booby", "brant", "cardinal", "condor", "coot", "crane"];
static var NAME_DELIMITER = ", ";
var capturedBirdCount = 0;
var CHAR_START = 65;
var doneLoading = false;
}
Symbol 320 MovieClip [__Packages.com.lumoslabs.games.birdwatching.StartEvent] Frame 0
class com.lumoslabs.games.birdwatching.StartEvent
{
var birdName;
function StartEvent (birdName) {
this.birdName = birdName;
}
}
Symbol 321 MovieClip [__Packages.com.lumoslabs.games.ResponseSoundEvent] Frame 0
class com.lumoslabs.games.ResponseSoundEvent
{
function ResponseSoundEvent () {
}
}
Symbol 322 MovieClip [__Packages.com.lumoslabs.games.birdwatching.LetterEvent] Frame 0
class com.lumoslabs.games.birdwatching.LetterEvent
{
var letters, trialsRemaining;
function LetterEvent (letters, trialsRemaining) {
this.letters = letters;
this.trialsRemaining = trialsRemaining;
}
}
Symbol 323 MovieClip [__Packages.com.lumoslabs.games.BadInputEvent] Frame 0
class com.lumoslabs.games.BadInputEvent
{
function BadInputEvent () {
}
}
Symbol 324 MovieClip [__Packages.com.lumoslabs.games.LastTrialEvent] Frame 0
class com.lumoslabs.games.LastTrialEvent
{
function LastTrialEvent () {
}
}
Symbol 325 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdCaptureEvent] Frame 0
class com.lumoslabs.games.birdwatching.BirdCaptureEvent
{
var letter, birdName, newBirdName, gotLetter, isCaptured, points, bonusPoints, exposures;
function BirdCaptureEvent (letter, birdName, newBirdName, gotLetter, isCaptured, points, bonusPoints, exposures) {
this.letter = letter;
this.birdName = birdName;
this.newBirdName = newBirdName;
this.gotLetter = gotLetter;
this.isCaptured = isCaptured;
this.points = points;
this.bonusPoints = bonusPoints;
this.exposures = exposures;
}
}
Symbol 326 MovieClip [__Packages.com.lumoslabs.games.BadGuessEvent] Frame 0
class com.lumoslabs.games.BadGuessEvent
{
var penaltyPoints;
function BadGuessEvent (penaltyPoints) {
this.penaltyPoints = penaltyPoints;
}
}
Symbol 327 MovieClip [__Packages.com.lumoslabs.games.birdwatching.SessionInfo] Frame 0
class com.lumoslabs.games.birdwatching.SessionInfo
{
var eccentricityArray, errorDistanceArray, medianError, letterResponseArray, birdCount, responseCount, score, sessionDifficulty, userLevel, userLevelUp, userLevelDown, scoreThreshold, positiveDistanceArray, lastBirdName, averageError, numCorrect;
function SessionInfo (eccentricityArray, errorDistanceArray, medianError, letterResponseArray, birdCount, endGame, responseCount, score, sessionDifficulty, userLevel, userLevelUp, userLevelDown, scoreThreshold, positiveDistanceArray, lastBirdName) {
this.eccentricityArray = eccentricityArray;
this.errorDistanceArray = errorDistanceArray;
this.medianError = medianError;
this.letterResponseArray = letterResponseArray;
this.birdCount = birdCount;
this.endGame = endGame;
this.responseCount = responseCount;
this.score = score;
this.sessionDifficulty = sessionDifficulty;
this.userLevel = userLevel;
this.userLevelUp = userLevelUp;
this.userLevelDown = userLevelDown;
this.scoreThreshold = scoreThreshold;
this.positiveDistanceArray = positiveDistanceArray;
this.lastBirdName = lastBirdName;
this.medianError = medianError;
averageError = getAverageError(errorDistanceArray);
numCorrect = positiveDistanceArray.length;
}
function getCorrectLetterFraction() {
var _local4 = 0;
var _local3 = 0;
var _local2;
_local2 = 0;
while (_local2 <= letterResponseArray.length) {
if (letterResponseArray[_local2] == "correct") {
_local3 = _local3 + 1;
} else if (letterResponseArray[_local2] == "wrong") {
_local4 = _local4 + 1;
}
_local2++;
}
if ((_local3 + _local4) == 0) {
return(0);
}
return(_local3 / (_local3 + _local4));
}
static function getAverageError(distanceArray) {
var _local2 = 0;
var _local1 = 0;
while (_local1 < distanceArray.length) {
_local2 = _local2 + distanceArray[_local1];
_local1++;
}
return(_local2 / distanceArray.length);
}
var endGame = false;
}
Symbol 328 MovieClip [__Packages.com.lumoslabs.games.birdwatching.StimulusCoordinates] Frame 0
class com.lumoslabs.games.birdwatching.StimulusCoordinates
{
var stimulusX, stimulusY, angle, radius, maxScreenRadiusWBorder, maxPossibleRadius;
function StimulusCoordinates (rMin, rMax, screenWidth, screenHeight) {
setCoordinates(rMin, rMax, screenWidth, screenHeight);
}
function setCoordinates(rMin, rMax, screenWidth, screenHeight) {
chooseCoordinates(rMin, rMax, screenWidth, screenHeight);
while (onStatusOrControls(stimulusX, stimulusY, screenWidth, screenHeight)) {
chooseCoordinates(rMin, rMax, screenWidth, screenHeight);
}
}
function chooseCoordinates(rMin, rMax, screenWidth, screenHeight) {
angle = chooseAngle();
radius = chooseRadius(angle, rMin, rMax, screenWidth, screenHeight);
stimulusX = convertToXCoordinate(angle, radius, screenWidth);
stimulusY = convertToYCoordinate(angle, radius, screenHeight);
}
function onStatusOrControls(x, y, screenWidth, screenHeight) {
var _local2 = (x > (screenWidth - 240)) && (y < 170);
var _local1 = (x > (screenWidth - 155)) && (y > (screenHeight - 90));
return(_local2 || (_local1));
}
function chooseAngle() {
return(Math.random() * 360);
}
function chooseRadius(angle, rMin, rMax, screenWidth, screenHeight) {
maxScreenRadiusWBorder = findScreenLimit(angle, screenWidth - (2 * BORDER), screenHeight - (2 * BORDER));
if (((rMax < maxScreenRadiusWBorder) && (rMax != null)) && (rMax != undefined)) {
maxPossibleRadius = rMax;
} else {
maxPossibleRadius = maxScreenRadiusWBorder;
}
if (maxPossibleRadius > rMin) {
radius = rMin + (Math.random() * (maxPossibleRadius - rMin));
} else {
radius = rMin;
trace("THE MAX RADIUS YOU SELECTED IS TOO SMALL. ECCENTRICITY DEFAULTS TO rMIN.");
}
return(radius);
}
function findScreenLimit(angle, screenWidth, screenHeight) {
var _local1;
if (Math.abs(Math.tan(angle)) > (screenHeight / screenWidth)) {
_local1 = (screenHeight / 2) / Math.abs(Math.sin(angle));
} else {
_local1 = (screenWidth / 2) / Math.abs(Math.cos(angle));
}
return(_local1);
}
function convertToXCoordinate(angle, radius, screenWidth) {
stimulusX = (radius * Math.cos(angle)) + (screenWidth / 2);
return(stimulusX);
}
function convertToYCoordinate(angle, radius, screenHeight) {
stimulusY = (radius * Math.sin(angle)) + (screenHeight / 2);
return(stimulusY);
}
function getStimulusX() {
return(stimulusX);
}
function getStimulusY() {
return(stimulusY);
}
function getRadius() {
return(radius);
}
var BORDER = 40;
}
Symbol 329 MovieClip [__Packages.com.lumoslabs.games.birdwatching.StimulusEvent] Frame 0
class com.lumoslabs.games.birdwatching.StimulusEvent
{
var x, y, duration, rMin, rMax, centralString, numberDistractors, level, trialCount;
function StimulusEvent (x, y, duration, useCentral, centralString, rMin, rMax, numberDistractors, difficulty, trialCount) {
this.x = x;
this.y = y;
this.duration = duration;
this.rMin = rMin;
this.rMax = rMax;
if (useCentral != null) {
this.useCentral = useCentral;
this.centralString = centralString;
}
this.numberDistractors = numberDistractors;
level = difficulty + 1;
this.trialCount = trialCount;
}
var useCentral = false;
}
Symbol 330 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdWatchingView] Frame 0
class com.lumoslabs.games.birdwatching.BirdWatchingView extends com.lumoslabs.games.GameView
{
var difficultyLevel, background, game_mc, getStatusBar, letterSelect, getController, soundEffects, startScreen, getModel, help_screen, level, delayIntervalID, stimulus_mc, centralStimulus_txt, feedbackPos_mc, feedbackNeg_mc, points_mc, revertMouse, transformMouse, central_mc, width, height, mouseView_mc, mouseDepth, x, y, model;
function BirdWatchingView (gameModel, controller, target, depth, x, y, width, height, difficultyLevel, evaluate, calibrate) {
super(gameModel, controller, target, depth, x, y, width, height);
this.difficultyLevel = difficultyLevel;
this.evaluate = evaluate;
this.calibrate = calibrate;
background = new com.lumoslabs.games.birdwatching.Background(game_mc, 0, x, y, width, height);
if (calibrate) {
getStatusBar().showPoints(false);
} else {
getStatusBar().showPoints(true);
background.loadRandomBackground();
}
initStimulus(stimulusDepth);
initFeedback(feedbackDepth);
initCentralView(centralTaskDepth);
initPointsDisplay();
letterSelect = new com.lumoslabs.games.birdwatching.BirdCaptureScreen(game_mc, com.lumoslabs.games.GameController(getController()), game_mc.getNextHighestDepth(), x, y, width, height, background, calibrate);
soundEffects = new com.lumoslabs.games.birdwatching.BirdWatchingSounds(target);
startScreen = new com.lumoslabs.games.birdwatching.StartScreen(com.lumoslabs.games.Game(getModel()), undefined, game_mc, game_mc.getNextHighestDepth(), 0, 0, width, height, difficultyLevel, background, evaluate, calibrate);
help_screen = com.lumoslabs.games.birdwatching.BirdWatchingHelpScreen(target.attachMovie("help_mc", "help_screen", target.getNextHighestDepth()));
help_screen.init(this);
}
function nextBackground() {
if ((!calibrate) && (background.switchBackground())) {
background.loadRandomBackground();
}
}
function getSounds() {
return(com.lumoslabs.games.birdwatching.BirdWatchingSounds(soundEffects));
}
function levelUp(level) {
levelChangeFlag = true;
this.level = level;
}
function updateLevel() {
if (levelChangeFlag) {
super.levelUp(level);
nextBackground();
}
levelChangeFlag = false;
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.birdwatching.StartEvent) {
nextBackground();
letterSelect.loadBird(infoObj.birdName);
} else if (infoObj instanceof com.lumoslabs.games.GameState) {
super.update(o, infoObj);
} else if (waitForEvent == true) {
eventQueue.push(infoObj);
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.StimulusEvent) {
fireStimulus(com.lumoslabs.games.birdwatching.StimulusEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.FeedbackEvent) {
doFeedback(com.lumoslabs.games.FeedbackEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.LetterEvent) {
showLetterSelect(com.lumoslabs.games.birdwatching.LetterEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.BirdCaptureEvent) {
doLetterPick(com.lumoslabs.games.birdwatching.BirdCaptureEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.BadInputEvent) {
doTryAgain(com.lumoslabs.games.BadInputEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.BadGuessEvent) {
doWrongGuess(com.lumoslabs.games.BadGuessEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.LastTrialEvent) {
doLastChance();
} else if (infoObj instanceof com.lumoslabs.games.ResponseSoundEvent) {
playResponseSound();
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.SessionInfo) {
handleSessionData(com.lumoslabs.games.birdwatching.SessionInfo(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.ResetEvent) {
resetViews();
} else {
super.update(o, infoObj);
}
}
function clearDelayInterval() {
clearInterval(delayIntervalID);
waitForEvent = false;
if (eventQueue.length > 0) {
update(getModel(), eventQueue.shift());
}
}
function clearStimulus() {
stimulus_mc._visible = false;
centralStimulus_txt.text = "";
var _local2 = 0;
while (_local2 < distractorArray.length) {
distractorArray[_local2]._visible = false;
_local2++;
}
clearDelayInterval();
updateAfterEvent();
}
function fireStimulus(stimulus) {
stimulus_mc._x = stimulus.x;
stimulus_mc._y = stimulus.y;
waitForEvent = true;
var owner = this;
getSounds().playStimulusSound(stimulus.level);
_root.onEnterFrame = function () {
owner.stimulus_mc._visible = true;
if (stimulus.useCentral) {
owner.showCentralStimulus(stimulus.centralString);
}
if (owner.useDistractors) {
owner.showDistractors(stimulus.rMin, stimulus.rMax, stimulus.numberDistractors);
}
owner.delayIntervalID = setInterval(owner, "clearStimulus", stimulus.duration);
delete _root.onEnterFrame;
};
}
function showCentralStimulus(birdLetter) {
centralStimulus_txt.text = birdLetter.toUpperCase();
}
function showDistractors(rMin, rMax, numberDistractors) {
if (numberDistractors != distractorArray.length) {
initDistractors(numberDistractors, distractorDepth);
}
var _local2;
_local2 = 0;
while (_local2 < numberDistractors) {
var _local3 = new com.lumoslabs.games.birdwatching.StimulusCoordinates(rMin, rMax, Stage.width, Stage.height);
distractorArray[_local2]._x = _local3.getStimulusX();
distractorArray[_local2]._y = _local3.getStimulusY();
distractorArray[_local2]._visible = true;
_local2++;
}
}
function doFeedback(feedback) {
var _local3;
if (feedback.isPositive) {
_local3 = feedbackPos_mc;
} else {
_local3 = feedbackNeg_mc;
}
_local3._x = feedback.x;
_local3._y = feedback.y;
trace("calibrate: " + calibrate);
if ((!calibrate) && (feedback.points > 0)) {
points_mc._visible = true;
points_mc.points_txt.text = ("+" + feedback.points) + "!";
}
if ((feedback.x < 100) || (feedback.y < 100)) {
points_mc._x = feedback.x + 50;
points_mc._y = feedback.y + 50;
} else {
points_mc._x = feedback.x - 50;
points_mc._y = feedback.y - 50;
}
_local3._visible = true;
stimulus_mc._visible = true;
delayIntervalID = setInterval(this, "clearFeedback", feedback.duration, _local3);
waitForEvent = true;
getSounds().feedbackSound(feedback.isPositive);
}
function clearFeedback(feedback_mc) {
clearDelayInterval();
clearStimulus();
feedback_mc._visible = false;
points_mc._visible = false;
}
function showLetterSelect(letterEvent) {
revertMouse();
if (letterEvent.trialsRemaining == 0) {
letterSelect.setLastTrialFlag();
}
letterSelect.showLetters(letterEvent.letters);
letterSelect.showLetterInstructions();
letterSelect.hideNextButton();
}
function hideInstructions() {
letterSelect.hideLetterInstructions();
}
function doLetterPick(captureEvent) {
revertMouse();
letterSelect.hideGuessWord_btn();
if (captureEvent.letter != null) {
letterSelect.doLetterPick(captureEvent);
}
if (captureEvent.gotLetter && (!captureEvent.isCaptured)) {
getSounds().goodLetterGuessSound();
} else if (!captureEvent.gotLetter) {
getSounds().badLetterGuessSound();
}
if (captureEvent.isCaptured) {
delayIntervalID = setInterval(this, "doCapture", DELAY, captureEvent);
} else {
delayIntervalID = setInterval(this, "finalizeLetterScreen", DELAY);
}
}
function doCapture(captureEvent) {
if (letterSelect.isAnimating()) {
return(undefined);
}
clearDelayInterval();
letterSelect.doCapture(captureEvent.birdName, captureEvent.newBirdName);
if (!calibrate) {
letterSelect.showBirdPoints(captureEvent.points, captureEvent.bonusPoints, captureEvent.exposures);
getSounds().goodWordGuessSound();
}
delayIntervalID = setInterval(this, "finalizeLetterScreen", DELAY);
}
function doLastChance() {
revertMouse();
letterSelect.showLastChance();
}
function doTryAgain() {
revertMouse();
letterSelect.doTryAgain();
}
function doWrongGuess(badGuessEvent) {
letterSelect.showPenaltyPoints(badGuessEvent.penaltyPoints);
getSounds().badWordGuessSound();
}
function playResponseSound() {
getSounds().playShutterSound();
}
function handleSessionData(sessionInfo) {
difficultyLevel = sessionInfo.userLevel;
if (sessionInfo.endGame) {
revertMouse();
var _local3 = letterSelect.getBirdCageXMax(game_mc, 522);
var _local4 = new com.lumoslabs.games.birdwatching.ConclusionScreen(com.lumoslabs.games.Game(getModel()), com.lumoslabs.games.GameController(getController()), sessionInfo, game_mc, game_mc.getNextHighestDepth(), evaluate, calibrate, background, _local3, sessionInfo.lastBirdName);
if (!calibrate) {
letterSelect.showBirdCage();
}
calibrate = false;
}
}
function finalizeLetterScreen() {
if (letterSelect.isAnimating()) {
return(undefined);
}
clearDelayInterval();
letterSelect.finish();
}
function clearLetterScreen() {
letterSelect.clear();
transformMouse();
}
function initStimulus(depth) {
stimulus_mc = game_mc.attachMovie(String(stimuli[0]), "stimulus", stimulusDepth);
stimulus_mc._x = Stage.width / 2;
stimulus_mc._y = Stage.height / 2;
stimulus_mc._visible = false;
}
function initFeedback(depth) {
feedbackPos_mc = game_mc.attachMovie("feedbackPos_mc", "feedbackPos_mc", depth);
feedbackPos_mc._x = 0;
feedbackPos_mc._y = 0;
feedbackPos_mc._visible = false;
feedbackNeg_mc = game_mc.attachMovie("feedbackNeg_mc", "feedbackNeg_mc", depth + 1);
feedbackNeg_mc._x = 0;
feedbackNeg_mc._y = 0;
feedbackNeg_mc._visible = false;
}
function initCentralView(depth) {
var _local2;
central_mc = game_mc.attachMovie("centralBox_mc", "central_mc", depth);
central_mc._x = width / 2;
central_mc._y = height / 2;
central_mc.createTextField("centralStimulus_txt", 0, -20, -30, 0, 0);
centralStimulus_txt = central_mc.centralStimulus_txt;
centralStimulus_txt.autoSize = true;
_local2 = new TextFormat();
_local2.size = 50;
_local2.font = "Arial";
_local2.align = "center";
centralStimulus_txt.setNewTextFormat(_local2);
}
function initDistractors(numberDistractors, depth) {
var _local2;
_local2 = 0;
while (_local2 < numberDistractors) {
distractorArray[_local2] = game_mc.attachMovie("distractor_mc", "distractor" + _local2, depth + _local2);
distractorArray[_local2]._visible = false;
_local2++;
}
}
function initPointsDisplay() {
game_mc.attachMovie("points_mc", "points_mc", game_mc.getNextHighestDepth());
points_mc = game_mc.points_mc;
points_mc._visible = false;
}
function loadStimulusImage(which) {
stimulus_mc.unloadMovie();
stimulus_mc = game_mc.attachMovie(String(stimuli[which % 3]), "stimulus", stimulusDepth);
}
function initMouse() {
Mouse.addListener(getController());
mouseView_mc = game_mc.attachMovie("crosshairs", "crosshairs_mc", mouseDepth);
mouseView_mc._visible = false;
}
function resetViews() {
letterSelect.removeClips();
delete letterSelect;
letterSelect = new com.lumoslabs.games.birdwatching.BirdCaptureScreen(game_mc, com.lumoslabs.games.GameController(getController()), game_mc.getNextHighestDepth(), x, y, width, height, background, calibrate);
nextBackground();
startScreen.destroy();
delete startScreen;
startScreen = new com.lumoslabs.games.birdwatching.StartScreen(com.lumoslabs.games.Game(getModel()), undefined, game_mc, game_mc.getNextHighestDepth(), 0, 0, width, height, difficultyLevel, background, evaluate, calibrate);
waitForEvent = false;
revertMouse();
}
function showDemo() {
revertMouse();
game_mc._visible = false;
levelChangeFlag = false;
clearInterval(delayIntervalID);
waitForEvent = false;
eventQueue = [];
help_screen.startHelp();
}
function endHelp() {
game_mc._visible = true;
com.lumoslabs.games.birdwatching.BirdWatchingGame(model).restart();
}
var levelChangeFlag = false;
var stimuli = new Array("bird1", "bird2", "bird3");
var waitForEvent = false;
var stimulusDepth = 100;
var feedbackDepth = 102;
var centralTaskDepth = 101;
var distractorDepth = 9;
var distractorArray = new Array();
var useDistractors = true;
var eventQueue = new Array();
var DELAY = 200;
var evaluate = false;
var calibrate = false;
}
Symbol 331 MovieClip [__Packages.com.lumoslabs.games.birdwatching.Background] Frame 0
class com.lumoslabs.games.birdwatching.Background
{
static var backgroundName;
var width, height, imageLoader, errorCount, parentClip, nextBackground_mc, oldBackground_mc, shade_mc, nextDepth, loadComplete;
function Background (target, depth, x, y, width, height) {
this.width = width;
this.height = height;
imageLoader = new MovieClipLoader();
imageLoader.addListener(this);
errorCount = 0;
buildBackground(target, depth, x, y, width, height);
loadDefaultBackground();
}
function buildBackground(target, depth, x, y) {
parentClip = target.createEmptyMovieClip("parentClip", depth);
parentClip._x = x;
parentClip._y = y;
nextBackground_mc = parentClip.createEmptyMovieClip("background_mc0", 0);
oldBackground_mc = parentClip.createEmptyMovieClip("background_mc1", 1);
shade_mc = parentClip.createEmptyMovieClip("shade_mc", 2);
nextDepth = 3;
drawShade(shade_mc, width, height);
showShade(false);
}
function loadDefaultBackground() {
backgroundName = defaultBackgroundName;
var _local2 = flash.display.BitmapData.loadBitmap(backgroundName);
nextBackground_mc.attachBitmap(_local2, 0);
nextBackground_mc._width = width;
nextBackground_mc._height = height;
}
function drawShade(clip, w, h) {
clip.moveTo(0, 0);
clip.beginFill(0);
clip._alpha = 50;
clip.lineTo(w, 0);
clip.lineTo(w, h);
clip.lineTo(0, h);
clip.lineTo(0, 0);
clip.endFill();
}
function showShade(show) {
shade_mc._visible = show;
}
function loadRandomBackground() {
loadComplete = false;
oldBackground_mc = nextBackground_mc;
nextBackground_mc = parentClip.createEmptyMovieClip("background_mc" + nextDepth, nextDepth);
nextDepth++;
shade_mc.swapDepths(nextBackground_mc.getDepth());
imageLoader.loadClip(getRandomBackgroundURL(), nextBackground_mc);
trace("loadBackground called");
}
function getRandomBackgroundURL() {
var _local1 = backgroundName;
while (backgroundName == _local1) {
backgroundName = backgroundNames[Math.floor(Math.random() * backgroundNames.length)];
}
return(com.lumoslabs.framework.ResourceHelper.getResourcePath(BACKGROUND_PATH + backgroundName));
}
function switchBackground() {
if (loadComplete) {
nextBackground_mc._visible = true;
oldBackground_mc.removeMovieClip();
return(true);
}
trace("next background not yet loaded");
return(false);
}
function onLoadInit(target) {
target._visible = false;
target._width = width;
target._height = height;
errorCount = 0;
loadComplete = true;
trace("background loaded");
}
function onLoadError(target, errorCode) {
trace("target: " + target);
trace("errorCode: " + errorCode);
trace("problem loading image, attempt to load new image");
errorCount++;
if (errorCount < 5) {
loadRandomBackground();
}
}
static var BACKGROUND_PATH = "bird_watching/backgrounds/";
static var backgroundNames = new Array("background1.jpg", "background2.jpg", "background3.jpg", "background4.jpg", "background5.jpg", "background7.jpg", "background8.jpg", "background9.jpg", "background10.jpg", "background11.jpg", "background14.jpg", "background15.jpg", "MoorSky.jpg", "YellowandBlue.jpg");
static var defaultBackgroundName = "background1.jpg";
}
Symbol 332 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdWatchingHelpScreen] Frame 0
class com.lumoslabs.games.birdwatching.BirdWatchingHelpScreen extends MovieClip
{
var stop, _visible, buttons, _width, _height, _x, _y, view, helpIndex, gotoAndStop;
function BirdWatchingHelpScreen () {
super();
stop();
_visible = false;
buttons.next.stop();
if (Stage.width < _width) {
_width = Stage.width;
_height = Stage.height;
} else {
_x = (Stage.width - _width) / 2;
_y = (Stage.height - _height) / 2;
}
}
function init(view) {
this.view = view;
var owner = this;
buttons.next.onPress = function () {
owner.nextHelp();
};
buttons.back.onPress = function () {
owner.backHelp();
};
}
function startHelp() {
helpIndex = 1;
doHelp();
}
function nextHelp() {
helpIndex++;
doHelp();
}
function backHelp() {
helpIndex--;
doHelp();
}
function doHelp() {
gotoAndStop(helpIndex);
_visible = true;
switch (helpIndex) {
case 1 :
buttons.back._visible = false;
break;
case 2 :
buttons.back._visible = true;
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
default :
_visible = false;
view.endHelp();
}
}
}
Symbol 333 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdCaptureScreen] Frame 0
class com.lumoslabs.games.birdwatching.BirdCaptureScreen
{
var controller, background, width, height, calibrate, keyReporter, capture_mc, tweenListener, captureContainer_mc, birdCage, background_mc, letterSelectInstructions_mc, wrong_mc, guessWordScreen_mc, inputText_txt, submit_btn, sorry_txt, birdPoints_mc, birdImage, next_btn, nextXLoc, nextYLoc, guessWord_btn, guessWordShade, guessPenalty_mc, wordSpace, pickButton, animationID, lastChance_mc;
function BirdCaptureScreen (target, controller, depth, x, y, width, height, background, calibrate) {
this.controller = controller;
this.background = background;
this.width = width;
this.height = height;
this.calibrate = calibrate;
keyReporter = new com.lumoslabs.ui.KeyReporter();
buildScreen(target, depth, x, y, width, height);
capture_mc._visible = false;
tweenListener = new Object();
tweenListener.onMotionFinished = com.lumoslabs.util.Delegate.create(this, doneAnimating);
}
function removeClips() {
captureContainer_mc.removeMovieClip();
}
function showBirdCage() {
birdCage.show();
}
function getBirdCageXMax(referenceClip, conclusionClipWidth) {
var _local2 = {x:(width - conclusionClipWidth) / 2, y:(height / 2) - 60};
birdCage.moveTo(_local2.x, _local2.y);
var _local3 = birdCage.getClip().getRect(referenceClip);
return(_local3.xMax);
}
function buildScreen(target, depth, x, y, width, height) {
captureContainer_mc = target.createEmptyMovieClip("captureContainer", depth);
capture_mc = captureContainer_mc.createEmptyMovieClip("captureScreen", 0);
capture_mc._x = x;
capture_mc._y = y;
background_mc = capture_mc.createEmptyMovieClip("background_mc", 0);
background_mc.moveTo(0, 0);
background_mc.lineTo(width, 0);
background_mc.lineTo(width, height);
background_mc.lineTo(0, height);
background_mc.lineTo(0, 0);
var _local4 = (height / 2) - 150;
var _local2 = 0;
while (_local2 < numButtons) {
capture_mc.attachMovie("letter_btn_mc", BUTTON + _local2, capture_mc.getNextHighestDepth());
if (_local2 == 0) {
capture_mc[BUTTON + _local2]._x = (width / 2) - (BTN_SIZE / 2);
} else if ((_local2 / 2) != Math.round(_local2 / 2)) {
capture_mc[BUTTON + _local2]._x = capture_mc[BUTTON + "0"]._x - ((BTN_SIZE + 20) * Math.round(_local2 / 2));
} else {
capture_mc[BUTTON + _local2]._x = capture_mc[BUTTON + "0"]._x + ((BTN_SIZE + 20) * (_local2 / 2));
}
capture_mc[BUTTON + _local2]._y = _local4;
capture_mc[BUTTON + _local2].button.enabled = false;
AsBroadcaster.initialize(capture_mc[BUTTON + _local2].button);
capture_mc[BUTTON + _local2].button.onRelease = function () {
this._parent.button.enabled = false;
this.broadcastMessage("letterClick", this._parent.button_txt.text);
};
capture_mc[BUTTON + _local2].button.addListener(controller);
_local2++;
}
capture_mc.attachMovie("letterSelectInstructions_mc", "letterSelectInstructions_mc", capture_mc.getNextHighestDepth());
letterSelectInstructions_mc = capture_mc.letterSelectInstructions_mc;
letterSelectInstructions_mc._x = width / 2;
letterSelectInstructions_mc._y = _local4 - 70;
wrong_mc = capture_mc.attachMovie("wrong_mc", "wrong", capture_mc.getNextHighestDepth());
wrong_mc._visible = false;
var _local6 = new TextFormat();
_local6.bold = true;
_local6.font = "Arial";
_local6.size = 32;
guessWordScreen_mc = capture_mc.attachMovie("guessWord_mc", "guessWord_mc", capture_mc.getNextHighestDepth());
guessWordScreen_mc._x = width / 2;
guessWordScreen_mc._y = (height / 2) - 100;
guessWordScreen_mc._visible = false;
inputText_txt = guessWordScreen_mc.guess_word_txt;
submit_btn = guessWordScreen_mc.guess_btn;
submit_btn.onRelease = com.lumoslabs.util.Delegate.create(this, submitGuess);
keyReporter.delegateKeyPressAction(13, this, submitGuess);
keyReporter.disable();
capture_mc.createTextField("sorry_txt", capture_mc.getNextHighestDepth(), width / 2, height / 3, 0, 0);
sorry_txt = capture_mc.sorry_txt;
sorry_txt.autoSize = "center";
sorry_txt.selectable = false;
sorry_txt.textColor = 16777215 /* 0xFFFFFF */;
sorry_txt.setNewTextFormat(_local6);
sorry_txt.text = TRY_AGAIN;
sorry_txt._visible = false;
birdCage = new com.lumoslabs.games.birdwatching.BirdCage(captureContainer_mc, captureContainer_mc.getNextHighestDepth(), 230, 330);
birdCage.hide();
capture_mc.attachMovie("birdPoints_mc", "birdPoints_mc", capture_mc.getNextHighestDepth());
birdPoints_mc = capture_mc.birdPoints_mc;
birdPoints_mc.gotoAndStop(1);
birdPoints_mc._x = width / 2;
birdPoints_mc._y = height / 2;
birdPoints_mc._visible = false;
birdImage = new com.lumoslabs.games.birdwatching.BirdImage(birdPoints_mc, birdCage.getLastPage());
var _local8 = birdPoints_mc.getRect(capture_mc);
next_btn = capture_mc.attachMovie("next_btn", "next_btn", capture_mc.getNextHighestDepth());
nextXLoc = ((width / 2) + (next_btn._width / 2)) + 10;
nextYLoc = (((2 * height) + birdPoints_mc._y) / 3) + 20;
next_btn._x = width / 2;
next_btn._y = nextYLoc;
next_btn.enabled = false;
next_btn._visible = false;
AsBroadcaster.initialize(next_btn);
next_btn.onRelease = function () {
this.broadcastMessage("nextClick");
};
next_btn.addListener(controller);
guessWord_btn = capture_mc.attachMovie("guessWord_btn", "guessWord_btn", capture_mc.getNextHighestDepth());
guessWord_btn._x = ((width / 2) - (guessWord_btn._width / 2)) - 10;
guessWord_btn._y = (((2 * height) + birdPoints_mc._y) / 3) + 20;
guessWordShade = capture_mc.attachMovie("guessWordShade", "guessWordShade", capture_mc.getNextHighestDepth(), {_x:guessWord_btn._x, _y:guessWord_btn._y, _visible:false});
AsBroadcaster.initialize(guessWord_btn);
guessWord_btn.onRelease = function () {
this.broadcastMessage("guessWordClick");
};
guessWord_btn.addListener(this);
hideGuessWord_btn();
capture_mc.attachMovie("guessPenalty_mc", "guessPenalty_mc", capture_mc.getNextHighestDepth());
guessPenalty_mc = capture_mc.guessPenalty_mc;
guessPenalty_mc._x = width / 2;
guessPenalty_mc._y = height / 2;
guessPenalty_mc._visible = false;
}
function guessWordClick() {
resetButtons();
hideGuessWord_btn();
hideLastChance();
guessWordScreen_mc._visible = true;
Selection.setFocus(inputText_txt);
keyReporter.enable();
}
function submitGuess() {
guessWordScreen_mc._visible = false;
controller.submitGuessClick(inputText_txt.text);
inputText_txt.text = "";
keyReporter.disable();
}
function onLetterClick(letter) {
disableLetterSelection();
controller.letterClick(letter);
if ((lastTrialFlag && (!birdIsCaptured)) && (!calibrate)) {
showLastChance();
}
lastTrialFlag = false;
}
function showLetters(letters) {
var _local4 = letters.length;
var _local3;
var _local2 = 0;
while (_local2 < _local4) {
_local3 = String(letters[_local2]);
capture_mc[BUTTON + _local2].button_txt.text = _local3;
capture_mc[BUTTON + _local2].enabled = true;
capture_mc[BUTTON + _local2]._alpha = 100;
capture_mc[BUTTON + _local2]._visible = true;
capture_mc[BUTTON + _local2].onRelease = com.lumoslabs.util.Delegate.create(this, onLetterClick, _local3);
keyReporter.delegateKeyPressAction(_local3.charCodeAt(0), this, onLetterClick, _local3);
_local2++;
}
keyReporter.enable();
background.showShade(true);
capture_mc._visible = true;
}
function showLetterInstructions() {
letterSelectInstructions_mc._visible = true;
}
function hideLetterInstructions() {
letterSelectInstructions_mc._visible = false;
}
function show() {
background.showShade(true);
capture_mc._visible = true;
}
function hide() {
background.showShade(false);
capture_mc._visible = false;
}
function clear() {
wordSpace.hide();
birdCage.hide();
guessWordScreen_mc._visible = false;
next_btn._visible = false;
next_btn.enabled = false;
sorry_txt._visible = false;
birdPoints_mc._visible = false;
guessPenalty_mc._visible = false;
letterSelectInstructions_mc._visible = false;
hideGuessWord_btn();
hide();
}
function doLetterPick(captureEvent) {
showNextButton();
if (wordSpace == undefined) {
wordSpace = new com.lumoslabs.games.birdwatching.WordSpace(capture_mc, capture_mc.getNextHighestDepth(), width / 2, (height / 2) + 60, captureEvent.birdName);
} else {
wordSpace.show();
}
if (captureEvent.gotLetter) {
doCorrectPick(captureEvent);
} else {
doIncorrectPick(captureEvent.letter);
}
}
function doCorrectPick(captureEvent) {
isolateButton(captureEvent.letter);
birdIsCaptured = captureEvent.isCaptured;
var _local4 = new mx.transitions.Tween(pickButton, "_width", mx.transitions.easing.Regular.easeOut, 80, 120, 1, true);
var _local3 = new mx.transitions.Tween(pickButton, "_height", mx.transitions.easing.Regular.easeOut, 80, 120, 1, true);
_local3.addListener(tweenListener);
animating = true;
wordSpace.addLetter(captureEvent.letter);
if (!captureEvent.isCaptured) {
showGuessWord_btn();
} else {
wordSpace.addLetter(captureEvent.birdName);
}
}
function doIncorrectPick(letter) {
isolateButton(letter);
wrong_mc._visible = true;
wrong_mc._x = pickButton._x - 10;
wrong_mc._y = pickButton._y - 10;
animating = true;
animationID = setInterval(this, "doneAnimating", 1000);
}
function showBirdPoints(points, bonusPoints, exposures) {
if (capture_mc._visible == false) {
return(undefined);
}
birdPoints_mc._visible = true;
birdPoints_mc.birdPoints_txt.text = "+" + points;
birdPoints_mc.bonusPoints_txt.text = "+" + bonusPoints;
birdPoints_mc.totalPoints_txt.text = ("+" + (points + bonusPoints)) + "!";
birdPoints_mc.exposures_txt.text = exposures;
}
function showPenaltyPoints(points) {
guessPenalty_mc._visible = true;
guessPenalty_mc.birdPoints_txt.text = points;
}
function doCapture(name, newName) {
guessWordScreen_mc._visible = false;
if (!calibrate) {
birdImage.showBirdAndClone();
birdCage.addBird(name, birdImage.getClone());
birdImage.loadBirdAndClone(newName, birdCage.getLastPage());
}
wordSpace.destroy();
delete wordSpace;
}
function loadBird(newName) {
birdImage.loadBirdAndClone(newName, birdCage.getLastPage());
}
function doTryAgain() {
sorry_txt._visible = true;
finish();
show();
}
function finish() {
resetButtons();
hideLetterInstructions();
showNextButton();
}
function resetButtons() {
var _local2 = 0;
while (_local2 < numButtons) {
if (capture_mc[BUTTON + _local2]._visible) {
capture_mc[BUTTON + _local2]._visible = false;
}
_local2++;
}
pickButton._width = BTN_SIZE;
pickButton._height = BTN_SIZE;
pickButton._visible = false;
wrong_mc._visible = false;
}
function disableLetterSelection() {
var _local2 = 0;
while (_local2 < numButtons) {
capture_mc[BUTTON + _local2].enabled = false;
keyReporter.clearKeyPressAction(capture_mc[BUTTON + _local2].button_txt.text.charCodeAt(0));
_local2++;
}
keyReporter.disable();
}
function isolateButton(letter) {
var _local3 = 0;
var _local2 = 0;
while (_local2 < numButtons) {
if (letter != capture_mc[BUTTON + _local2].button_txt.text) {
com.lumoslabs.util.Animate.fadeMovie(capture_mc[BUTTON + _local2], 20);
} else {
_local3 = _local2;
}
_local2++;
}
pickButton = capture_mc[BUTTON + _local3];
}
function isAnimating() {
return(animating || (wordSpace.isAnimating()));
}
function doneAnimating() {
if (animationID != undefined) {
clearInterval(animationID);
animationID = undefined;
}
animating = false;
}
function hideGuessWord_btn() {
guessWordShade._visible = false;
guessWord_btn._visible = false;
guessWord_btn.enabled = false;
next_btn._x = width / 2;
next_btn._y = nextYLoc;
}
function showGuessWord_btn() {
guessWord_btn._visible = true;
next_btn._x = nextXLoc;
next_btn._y = nextYLoc;
if (calibrate) {
guessWord_btn.enabled = false;
guessWordShade._visible = true;
trace("guessWordShade: " + guessWordShade);
trace("guessWordShade._x: " + guessWordShade._x);
trace("guessWordShade._y: " + guessWordShade._y);
trace("guessWordShade._visible: " + guessWordShade._visible);
} else {
guessWord_btn.enabled = true;
}
}
function showNextButton() {
next_btn._visible = true;
next_btn.enabled = true;
}
function hideNextButton() {
next_btn._visible = false;
}
function showLastChance() {
if (!calibrate) {
capture_mc.attachMovie("lastChance_mc", "lastChance_mc", capture_mc.getNextHighestDepth());
lastChance_mc = capture_mc.lastChance_mc;
lastChance_mc._x = Stage.width / 2;
lastChance_mc._y = (Stage.height / 2) - 200;
}
show();
wordSpace.show();
showNextButton();
showGuessWord_btn();
}
function hideLastChance() {
lastChance_mc._visible = false;
lastChance_mc.enabled = false;
}
function setLastTrialFlag() {
lastTrialFlag = true;
}
var numButtons = 5;
var lastTrialFlag = false;
var birdIsCaptured = false;
var animating = false;
static var BUTTON = "letter_btn";
static var BTN_SIZE = 80;
static var TRY_AGAIN = "Sorry, You Missed!";
static var GUESS_INSTRUCTIONS = "What is the bird name?";
static var LETTER_SELECT_INSTRUCTIONS = "Select the letter that appeared:";
}
Symbol 334 MovieClip [__Packages.com.lumoslabs.games.birdwatching.WordSpace] Frame 0
class com.lumoslabs.games.birdwatching.WordSpace
{
var letters, tweenListener, wordSpace_mc;
function WordSpace (target, depth, x, y, name) {
letters = name.split("");
var _local2 = (x - ((letters.length / 2) * (letterWidth + gapWidth))) + gapWidth;
buildWordSpace(target, depth, _local2, y, letters.length);
tweenListener = new Object();
tweenListener.onMotionFinished = com.lumoslabs.util.Delegate.create(this, doneAnimating);
}
function buildWordSpace(target, depth, x, y, letterCount) {
wordSpace_mc = target.createEmptyMovieClip("wordSpace", depth);
wordSpace_mc._x = x;
wordSpace_mc._y = y;
wordSpace_mc.lineStyle(lineWidth, 268435455, 100, false, "none", "none");
var _local2 = 0;
var _local4 = letterHeight + lineWidth;
var _local3 = 0;
while (_local3 < letterCount) {
wordSpace_mc.moveTo(_local2, _local4);
_local2 = _local2 + letterWidth;
wordSpace_mc.lineTo(_local2, _local4);
_local2 = _local2 + gapWidth;
_local3++;
}
}
function show() {
wordSpace_mc._visible = true;
}
function hide() {
wordSpace_mc._visible = false;
}
function addLetter(letter) {
trace("adding letter");
var _local3;
var _local2;
var _local5;
_local2 = 0;
while (_local2 < letters.length) {
if (letters[_local2] == letter) {
_local3 = wordSpace_mc.attachMovie("letterTile_mc", "letter" + _local2, _local2 + 1);
_local3.letter_txt.text = letter;
_local3._width = letterWidth;
_local3._height = letterHeight;
_local3._x = _local2 * (letterWidth + gapWidth);
_local5 = new mx.transitions.Tween(_local3, "_alpha", mx.transitions.easing.Regular.easeIn, 0, 100, 1, true);
}
_local2++;
}
_local5.addListener(tweenListener);
animating = true;
}
function isAnimating() {
return(animating);
}
function doneAnimating() {
animating = false;
}
function destroy() {
delete tweenListener;
wordSpace_mc.removeMovieClip();
}
var letterWidth = 40;
var letterHeight = 40;
var gapWidth = 10;
var lineWidth = 5;
var animating = false;
}
Symbol 335 MovieClip [__Packages.mx.transitions.easing.Regular] Frame 0
class mx.transitions.easing.Regular
{
function Regular () {
}
static function easeIn(t, b, c, d) {
t = t / d;
return(((c * t) * t) + b);
}
static function easeOut(t, b, c, d) {
t = t / d;
return((((-c) * t) * (t - 2)) + b);
}
static function easeInOut(t, b, c, d) {
t = t / (d / 2);
if (t < 1) {
return((((c / 2) * t) * t) + b);
}
t--;
return((((-c) / 2) * ((t * (t - 2)) - 1)) + b);
}
static var version = "1.1.0.52";
}
Symbol 336 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdCage] Frame 0
class com.lumoslabs.games.birdwatching.BirdCage
{
var birdCage_mc, title_txt, textFormat, pages, pageIndex, newPagePending, newPage, lineY, line, new_txt;
function BirdCage (target, depth, x, y, width, height) {
initTextFormat();
buildBirdCage(target, depth, x, y);
}
function moveTo(x, y) {
birdCage_mc._x = x;
birdCage_mc._y = y;
}
function getClip() {
return(birdCage_mc);
}
function buildBirdCage(target, depth, x, y) {
birdCage_mc = target.attachMovie("birdCage_mc", "birdCage_mc", depth);
birdCage_mc._x = x;
birdCage_mc._y = y;
setupButtons();
birdCage_mc.createTextField("title_txt", 1, -105, -170, 0, 0);
title_txt = birdCage_mc.title_txt;
title_txt.autoSize = "left";
title_txt.selectable = false;
title_txt.textColor = 0;
title_txt.setNewTextFormat(textFormat);
title_txt.text = TITLE_TXT;
pages = new Array();
startNewPage(birdCage_mc.createEmptyMovieClip("page0", birdCage_mc.getNextHighestDepth()));
}
function setupButtons() {
var owner = this;
birdCage_mc.backButton.onPress = function () {
owner.turnPageBack();
};
birdCage_mc.forwardButton.onPress = function () {
owner.turnPageForward();
};
birdCage_mc.forwardButton.onRollOver = function () {
this.gotoAndStop("over");
};
birdCage_mc.backButton.onRollOver = function () {
this.gotoAndStop("over");
};
birdCage_mc.forwardButton.onRollOut = function () {
this.gotoAndStop("enabled");
};
birdCage_mc.backButton.onRollOut = function () {
this.gotoAndStop("enabled");
};
enableBackButton(false);
enableForwardButton(false);
}
function enableBackButton(enable) {
if (enable) {
birdCage_mc.backButton.gotoAndStop("enabled");
} else {
birdCage_mc.backButton.gotoAndStop("disabled");
}
birdCage_mc.backButton.enabled = enable;
}
function enableForwardButton(enable) {
if (enable) {
birdCage_mc.forwardButton.gotoAndStop("enabled");
} else {
birdCage_mc.forwardButton.gotoAndStop("disabled");
}
birdCage_mc.forwardButton.enabled = enable;
}
function initTextFormat() {
textFormat = new TextFormat();
textFormat.bold = true;
textFormat.font = "Arial";
textFormat.size = 18;
textFormat.align = "center";
}
function show() {
gotoPage(0);
birdCage_mc._visible = true;
}
function gotoPage(index) {
pages[pageIndex]._visible = false;
pageIndex = index;
pages[pageIndex]._visible = true;
if (pageIndex == 0) {
enableBackButton(false);
} else {
enableBackButton(true);
}
if (pageIndex == (pages.length - 1)) {
enableForwardButton(false);
} else {
enableForwardButton(true);
}
}
function turnPageForward() {
if (pageIndex < (pages.length - 1)) {
gotoPage(pageIndex + 1);
}
}
function turnPageBack() {
if (pageIndex > 0) {
gotoPage(pageIndex - 1);
}
}
function hide() {
birdCage_mc._visible = false;
}
function addBird(name, birdClip) {
trace("adding " + name);
if (newPagePending) {
startNewPage(newPage);
}
addImage(birdClip);
addText(name);
if ((lineY + 270) > lineYMax) {
newPage = birdCage_mc.createEmptyMovieClip("page" + pages.length, birdCage_mc.getNextHighestDepth());
newPagePending = true;
}
}
function startNewPage(page) {
line = 0;
lineY = title_txt.textHeight - 150;
pages.push(page);
gotoPage(pages.length - 1);
newPagePending = false;
}
function addText(text) {
var _local2 = getLastPage();
_local2.createTextField(("bird" + line) + "_txt", _local2.getNextHighestDepth(), 0, lineY, 0, 0);
new_txt = _local2[("bird" + line) + "_txt"];
new_txt.autoSize = "left";
new_txt.selectable = false;
new_txt.textColor = 0;
new_txt.setNewTextFormat(textFormat);
new_txt.text = doCapitalization(text);
new_txt._x = ((-new_txt._width) / 2) + 10;
lineY = lineY + (new_txt._height + 10);
line++;
}
function addImage(birdClip) {
var _local3;
if (birdClip._width > birdClip._height) {
_local3 = 13000 / birdClip._width;
} else {
_local3 = 13000 / birdClip._height;
}
birdClip._xscale = _local3;
birdClip._yscale = _local3;
birdClip._x = ((-birdClip._width) / 2) + 10;
birdClip._y = lineY;
com.lumoslabs.util.BitmapHelper.smooth(birdClip);
birdClip._visible = true;
lineY = lineY + (birdClip._height + 5);
}
function getLastPage() {
if (newPagePending) {
return(newPage);
}
return(pages[pages.length - 1]);
}
function doCapitalization(text) {
var _local2;
var _local3;
text = text.toLowerCase();
_local2 = text.charAt(0);
_local2 = _local2.toUpperCase();
_local3 = text.substring(1);
text = _local2.concat(_local3);
return(text);
}
static var lineYMax = 330;
static var WIDTH = 200;
static var HEIGHT = 400;
static var TITLE_TXT = "CAPTURED BIRDS:";
}
Symbol 337 MovieClip [__Packages.com.lumoslabs.util.BitmapHelper] Frame 0
class com.lumoslabs.util.BitmapHelper
{
function BitmapHelper () {
}
static function smooth(clip) {
var _local2 = new flash.display.BitmapData((clip._width * 100) / clip._xscale, (clip._height * 100) / clip._yscale, true, 0);
_local2.draw(clip);
clip.attachBitmap(_local2, 0, "always", true);
}
static function clone(originalClip, cloneClip) {
var _local2 = new flash.display.BitmapData((originalClip._width * 100) / originalClip._xscale, (originalClip._height * 100) / originalClip._yscale, true, 0);
_local2.draw(originalClip);
cloneClip.attachBitmap(_local2, 0);
}
static function replaceWithClip(inClip, smoothing) {
var _local2 = inClip._parent.createEmptyMovieClip(inClip._name + "Bitmap", inClip._parent.getNextHighestDepth());
draw(inClip, _local2, smoothing);
replace(inClip, _local2);
return(_local2);
}
static function draw(inClip, outClip, smoothing) {
var _local1 = inClip.getBounds(inClip);
var _local6 = _local1.xMax - _local1.xMin;
var _local7 = _local1.yMax - _local1.yMin;
var _local2 = new flash.geom.Matrix();
_local2.tx = -_local1.xMin;
_local2.ty = -_local1.yMin;
var _local4 = new flash.display.BitmapData(_local6, _local7, true, 0);
_local4.draw(inClip, _local2, null, null, null, smoothing);
_local2.tx = _local1.xMin;
_local2.ty = _local1.yMin;
outClip.beginBitmapFill(_local4, _local2, false, smoothing);
outClip.moveTo(_local1.xMin, _local1.yMin);
outClip.lineTo(_local1.xMax, _local1.yMin);
outClip.lineTo(_local1.xMax, _local1.yMax);
outClip.lineTo(_local1.xMin, _local1.yMax);
outClip.lineTo(_local1.xMin, _local1.yMin);
outClip.endFill();
}
static function replace(inClip, outClip) {
if (inClip._parent == outClip._parent) {
outClip._x = inClip._x;
outClip._y = inClip._y;
outClip.swapDepths(inClip);
inClip.removeMovieClip();
}
}
}
Symbol 338 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdImage] Frame 0
class com.lumoslabs.games.birdwatching.BirdImage
{
var birdPoints_mc, parentClip, birdClips, nextIndex, nextBirdClip, defaultClip, pageClip, birdImageLoader, birdImageListener, defaultImageBmp, nextName, cloneClip;
function BirdImage (target, pageClip) {
setupImageLoader();
birdPoints_mc = target;
parentClip = birdPoints_mc.createEmptyMovieClip("parentClip", birdPoints_mc.getNextHighestDepth());
birdClips = new Array();
birdClips[0] = parentClip.createEmptyMovieClip("birdClip0", 0);
birdClips[1] = parentClip.createEmptyMovieClip("birdClip1", 1);
nextIndex = 0;
nextBirdClip = birdClips[nextIndex];
defaultClip = parentClip.createEmptyMovieClip("defaultClip", 2);
loadDefaultBird(defaultClip);
this.pageClip = pageClip;
}
function setupImageLoader() {
birdImageLoader.removeListener(birdImageListener);
delete birdImageLoader;
delete birdImageListener;
birdImageLoader = new MovieClipLoader();
birdImageListener = new Object();
birdImageListener.loadComplete = false;
birdImageLoader.addListener(birdImageListener);
setupImageListener();
}
function setupImageListener() {
birdImageListener.onLoadError = function (target, errorCode) {
trace("load error for bird image: " + errorCode);
trace("target: " + target);
};
birdImageListener.onLoadInit = function (target) {
this.loadComplete = true;
target._visible = false;
trace("bird image loaded");
};
}
function loadDefaultBird(birdClip) {
defaultImageBmp = flash.display.BitmapData.loadBitmap("default_bird.jpg");
birdClip.attachBitmap(defaultImageBmp, 0);
}
function loadBirdAndClone(birdName, pageClip) {
trace("loadBird called");
setupImageLoader();
nextName = birdName;
this.pageClip = pageClip;
nextBirdClip.birdLinkClip.unloadMovie();
nextBirdClip.birdLinkClip.removeMovieClip();
delete nextBirdClip.birdLinkClip;
nextBirdClip.birdLinkClip = nextBirdClip.createEmptyMovieClip(nextName.toLowerCase() + "BirdLink", pageClip.getNextHighestDepth());
nextBirdClip.birdLinkClip.birdTempClip = nextBirdClip.birdLinkClip.createEmptyMovieClip(nextName.toLowerCase() + "BirdTemp", pageClip.getNextHighestDepth());
birdImageLoader.loadClip(getBirdURL(nextName), nextBirdClip.birdLinkClip.birdTempClip);
}
function getBirdURL(birdName) {
return(com.lumoslabs.framework.ResourceHelper.getResourcePath((IMAGE_PATH + birdName.toLowerCase()) + ".jpg"));
}
function showBirdAndClone() {
birdPoints_mc.birdName_mc.field.text = getBirdNameText(nextName);
if (birdImageListener.loadComplete) {
cloneClip = pageClip.createEmptyMovieClip(nextName.toLowerCase() + "Clone", pageClip.getNextHighestDepth());
com.lumoslabs.util.BitmapHelper.clone(nextBirdClip.birdLinkClip.birdTempClip, cloneClip);
arrangeBirdImage(nextBirdClip.birdLinkClip.birdTempClip);
switchClips();
defaultClip._visible = false;
} else {
nextBirdClip.birdLinkClip.unloadMovie();
nextBirdClip.birdLinkClip.removeMovieClip();
delete nextBirdClip.birdLinkClip;
arrangeBirdImage(defaultClip);
birdClips[(nextIndex + 1) % 2]._visible = false;
cloneClip = pageClip.createEmptyMovieClip(nextName.toLowerCase() + "DefaultClone", pageClip.getNextHighestDepth());
cloneClip.attachBitmap(defaultImageBmp, 0);
}
cloneClip._visible = true;
}
function switchClips() {
nextBirdClip._visible = true;
nextIndex = (nextIndex + 1) % 2;
nextBirdClip = birdClips[nextIndex];
nextBirdClip._visible = false;
}
function getBirdNameText(capsName) {
var _local1 = capsName.charAt(0);
if (((((_local1 == "A") || (_local1 == "E")) || (_local1 == "I")) || (_local1 == "O")) || (_local1 == "U")) {
return((("an " + _local1) + capsName.slice(1).toLowerCase()) + "!");
}
return((("a " + _local1) + capsName.slice(1).toLowerCase()) + "!");
}
function getClone() {
return(cloneClip);
}
function arrangeBirdImage(imageClip) {
if (imageClip._width >= imageClip._height) {
birdPoints_mc.gotoAndStop(1);
} else {
birdPoints_mc.gotoAndStop(2);
}
var _local4 = birdPoints_mc.imageBorder.getRect(birdPoints_mc);
var _local5 = _local4.xMax - _local4.xMin;
var _local6 = _local4.yMax - _local4.yMin;
var _local3 = 100;
if (imageClip._width < _local5) {
_local3 = _local3 * (_local5 / imageClip._width);
imageClip._xscale = _local3;
imageClip._yscale = _local3;
}
if (imageClip._height < _local6) {
_local3 = _local3 * (_local6 / imageClip._Height);
imageClip._xscale = _local3;
imageClip._yscale = _local3;
}
if (imageClip._width > _local5) {
_local3 = _local3 * (_local5 / imageClip._width);
imageClip._xscale = _local3;
imageClip._yscale = _local3;
}
if (imageClip._height > _local6) {
_local3 = _local3 * (_local6 / imageClip._Height);
imageClip._xscale = _local3;
imageClip._yscale = _local3;
}
imageClip._x = _local4.xMin;
imageClip._y = _local4.yMin;
com.lumoslabs.util.BitmapHelper.smooth(imageClip);
imageClip._visible = true;
}
static var IMAGE_PATH = "bird_watching/bird_images/";
}
Symbol 339 MovieClip [__Packages.com.lumoslabs.ui.KeyReporter] Frame 0
class com.lumoslabs.ui.KeyReporter
{
var keyActions;
function KeyReporter () {
Key.addListener(this);
keyActions = new Object();
}
function delegateKeyPressAction(keyCode, scope, method) {
var parameters_arr = arguments.slice(3);
keyActions[keyCode] = function () {
method.apply(scope, arguments.concat(parameters_arr));
};
}
function clearKeyPressAction(keyCode) {
delete keyActions[keyCode];
}
function onKeyDown(code) {
if (enabled) {
var _local2 = Function(keyActions[Key.getCode()]);
if (_local2 != undefined) {
_local2.call();
}
}
}
function enable() {
enabled = true;
}
function disable() {
enabled = false;
}
function destory() {
Key.removeListener(this);
delete keyActions;
}
var enabled = true;
}
Symbol 340 MovieClip [__Packages.com.lumoslabs.util.Animate] Frame 0
class com.lumoslabs.util.Animate
{
function Animate () {
}
static function initClip(clip, listener) {
if (listener != undefined) {
if (clip._listeners == undefined) {
AsBroadcaster.initialize(clip);
}
clip.addListener(listener);
}
}
static function fadeMovie(clip, increment, listener, finalize) {
initClip(clip, listener);
clip.onEnterFrame = function () {
clip._alpha = clip._alpha - increment;
if (clip._alpha <= 0) {
clip._visible = false;
delete clip.onEnterFrame;
clip.broadcastMessage(finalize);
}
};
}
static function fadeInMovie(clip, increment, listener, finalize) {
initClip(clip, listener);
clip._alpha = 0;
clip.onEnterFrame = function () {
clip._alpha = clip._alpha + increment;
if (clip._alpha >= 100) {
delete clip.onEnterFrame;
clip.broadcastMessage(finalize);
}
};
}
static function moveMovie(clip, increment, destX, destY, listener, finalize) {
var _local3;
var _local2;
clip.onEnterFrame = function () {
};
}
static function zoomMovie(clip, increment, maxWidth, listener, finalize) {
initClip(clip, listener);
clip.onEnterFrame = function () {
clip._width = clip._width + increment;
clip._height = clip._height + increment;
clip._x = clip._x - (increment / 2);
if (clip._width >= maxWidth) {
delete clip.onEnterFrame;
clip.broadcastMessage(finalize);
}
};
}
}
Symbol 341 MovieClip [__Packages.com.lumoslabs.games.birdwatching.ConclusionScreen] Frame 0
class com.lumoslabs.games.birdwatching.ConclusionScreen extends com.lumoslabs.util.AbstractView
{
var sessionInfo, target, depth, controller, evaluate, calibrate, background, model, textContainer_mc, conclusionContainer_mc, containerWidth, containerHeight, birdCount_txt, score_txt, unlockLevel_txt, playAgain_btn;
function ConclusionScreen (gameModel, controller, sessionInfo, target, depth, evaluate, calibrate, background, xOffset) {
super(gameModel, controller);
this.sessionInfo = sessionInfo;
this.target = target;
this.depth = depth;
this.controller = controller;
this.evaluate = evaluate;
this.calibrate = calibrate;
this.background = background;
model.addObserver(this);
buildView(xOffset);
background.showShade(true);
}
function getClip() {
return(textContainer_mc);
}
function buildView(xOffset) {
conclusionContainer_mc = target.createEmptyMovieClip("conclusionContainer", depth);
var _local2 = conclusionContainer_mc.createEmptyMovieClip("fill", conclusionContainer_mc.getNextHighestDepth());
_local2.moveTo(0, 0);
_local2.lineTo(Stage.width, 0);
_local2.lineTo(Stage.width, Stage.height);
_local2.lineTo(0, Stage.height);
_local2.lineTo(0, 0);
containerWidth = conclusionContainer_mc._width;
containerHeight = conclusionContainer_mc._height;
textContainer_mc = conclusionContainer_mc.attachMovie("textContainer_mc", "textContainer_mc", 0);
textContainer_mc._x = xOffset + (textContainer_mc._width / 2);
textContainer_mc._y = (containerHeight / 2) - 100;
textContainer_mc._alpha = 200;
var _local6;
var _local7;
var _local5;
var _local13 = -180;
var _local12 = -110;
_local6 = new TextFormat();
_local6.size = 25;
_local6.font = "Verdana";
_local6.color = 16777215 /* 0xFFFFFF */;
_local6.bold = false;
_local5 = new TextFormat();
_local5.size = 40;
_local5.font = "Verdana";
_local5.color = 16776960 /* 0xFFFF00 */;
_local5.bold = false;
_local7 = new TextFormat();
_local7.size = 22;
_local7.font = "Verdana";
_local7.color = 16776960 /* 0xFFFF00 */;
birdCount_txt = textContainer_mc.birdCount_txt;
if (calibrate) {
birdCount_txt.text = "Congratulations!";
} else {
switch (sessionInfo.birdCount) {
case 0 :
trace("NO BIRDS");
birdCount_txt.text = "You did not catch any birds.";
break;
case 1 :
birdCount_txt.text = ("You caught " + sessionInfo.birdCount) + " bird.";
break;
default :
birdCount_txt.text = ("You caught " + sessionInfo.birdCount) + " birds!";
}
}
if (calibrate || (sessionInfo.lastBirdName == undefined)) {
textContainer_mc.missedBird_txt.text = "";
} else {
textContainer_mc.missedBird_txt.text = ("You missed \"" + sessionInfo.lastBirdName.toLowerCase()) + "\".";
}
score_txt = textContainer_mc.score_txt;
if (calibrate) {
score_txt.text = "";
} else {
score_txt.text = "Score = " + Math.round(sessionInfo.score);
}
unlockLevel_txt = textContainer_mc.unlockLevel_txt;
if (evaluate) {
unlockLevel_txt.text = "";
} else if (calibrate) {
unlockLevel_txt.text = ("Calibration complete! Your starting level is " + sessionInfo.userLevel) + ".";
} else if ((sessionInfo.userLevel >= 10) && (!sessionInfo.userLevelUp)) {
unlockLevel_txt.text = "You've unlocked all the levels.";
} else if (sessionInfo.userLevelUp) {
unlockLevel_txt.text = ("Congratulations! You unlocked level " + sessionInfo.userLevel) + ".";
} else if ((sessionInfo.userLevel == sessionInfo.sessionDifficulty) || (sessionInfo.userLevelDown)) {
unlockLevel_txt.text = ("You need " + sessionInfo.scoreThreshold) + " points to unlock the next difficulty level.";
} else {
unlockLevel_txt.text = "You need to play your highest level to unlock the next level.";
}
var _local9 = Math.round(100 * (sessionInfo.positiveDistanceArray.length / sessionInfo.errorDistanceArray.length));
var _local8 = sessionInfo.medianError;
var _local10 = Math.round(100 * sessionInfo.getCorrectLetterFraction());
textContainer_mc.detectionNum_txt.text = _local9 + "%";
textContainer_mc.precisionNum_txt.text = _local8;
textContainer_mc.letterIDNum_txt.text = _local10 + "%";
setText(textContainer_mc.detectionTxt_txt, detectionRanges, _local9, rangesText);
setText(textContainer_mc.letterIDTxt_txt, letterIDRanges, _local10, rangesText);
rangesText.reverse();
setText(textContainer_mc.precisionTxt_txt, precisionRanges, _local8, rangesText);
rangesText.reverse();
if (calibrate) {
textContainer_mc._x = Stage.width / 2;
var _local3 = conclusionContainer_mc.attachMovie("play_btn", "play_button", conclusionContainer_mc.getNextHighestDepth());
_local3._x = xOffset + (_local3._width / 2);
_local3._y = (containerHeight * 9) / 10;
_local3._alpha = 200;
_local3.onRelease = com.lumoslabs.util.Delegate.create(controller, controller.restartClick);
} else {
var _local4 = conclusionContainer_mc.attachMovie("done_btn", "Done_button", conclusionContainer_mc.getNextHighestDepth());
_local4._x = xOffset + (_local4._width / 2);
_local4._y = (containerHeight * 9) / 10;
_local4._alpha = 200;
_local4.onRelease = com.lumoslabs.util.Delegate.create(controller, controller.doneClick);
}
}
function setText(txt, ranges, value, rangesString) {
var _local1;
_local1 = 0;
while (_local1 < ranges.length) {
if (value >= ranges[_local1]) {
txt.text = rangesString[_local1];
return(undefined);
}
_local1++;
}
txt.text = rangesString[_local1];
}
function addPlayAgainButton() {
playAgain_btn = conclusionContainer_mc.attachMovie("playAgain_btn", "playAgain_btn", conclusionContainer_mc.getNextHighestDepth());
playAgain_btn._x = (containerWidth - (playAgain_btn._width / 2)) - 20;
playAgain_btn._y = (containerHeight - (playAgain_btn._height / 2)) - 20;
playAgain_btn._alpha = 200;
AsBroadcaster.initialize(playAgain_btn);
playAgain_btn.onRelease = function () {
this.broadcastMessage("restartClick");
};
playAgain_btn.addListener(controller);
}
function getFieldOfViewText() {
var _local2 = getFieldOfView();
if ((sessionInfo.sessionDifficulty == 0) && (_local2 < 10)) {
return(("Your useful field of view is " + _local2) + " degrees");
}
if ((sessionInfo.sessionDifficulty == 0) && (_local2 >= 10)) {
return("Your useful field of view is at least 10 degrees. You should try a harder level.");
}
if ((sessionInfo.sessionDifficulty == 1) && (_local2 < 20)) {
return(("Your useful field of view is " + _local2) + " degrees");
}
if ((sessionInfo.sessionDifficulty == 1) && (_local2 >= 20)) {
return("Your useful field of view is at least 20 degrees. You should try a harder level.");
}
if ((sessionInfo.sessionDifficulty == 2) && (_local2 < 30)) {
return(("Your useful field of view is " + _local2) + " degrees");
}
if ((sessionInfo.sessionDifficulty == 2) && (_local2 >= 30)) {
return("Your useful field of view is at least 30 degrees. You should try a harder level.");
}
}
function getFieldOfView() {
var _local2;
_local2 = (((2 * sessionInfo.sessionDifficulty) + sessionInfo.getCorrectLetterFraction()) * 150) / sessionInfo.averageError;
return(Math.round(_local2));
}
function defaultController(model) {
return(new com.lumoslabs.games.GameController(model, undefined));
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.ResetEvent) {
destroy();
}
}
function destroy() {
background.showShade(false);
conclusionContainer_mc.removeMovieClip();
model.removeObserver(this);
}
static var rangesText = ["excellent", "great", "very good", "good", "fair", "poor"];
static var detectionRanges = [90, 80, 70, 60, 10];
static var precisionRanges = [150, 50, 23, 18, 13];
static var letterIDRanges = [90, 80, 70, 60, 10];
}
Symbol 342 MovieClip [__Packages.com.lumoslabs.games.birdwatching.StartScreen] Frame 0
class com.lumoslabs.games.birdwatching.StartScreen extends com.lumoslabs.util.AbstractView
{
var model, difficultyLevel, background, start_mc, instructionsContainer_mc, getController, background_mc, controller;
function StartScreen (gameModel, controller, target, depth, x, y, width, height, difficultyLevel, background, evaluate, calibrate) {
super(gameModel, controller);
model.addObserver(this);
this.difficultyLevel = difficultyLevel;
this.background = background;
addStartScreen(target, depth, x, y, width, height, evaluate, calibrate);
createLevelSlider(width, height, numButtons, evaluate, calibrate);
}
function createTestButton(width, height) {
var _local2 = start_mc.attachMovie("start_btn", "start_btn", start_mc.getNextHighestDepth());
_local2._x = instructionsContainer_mc._x;
_local2._y = instructionsContainer_mc._y + 80;
AsBroadcaster.initialize(_local2);
_local2.onRelease = function () {
this.broadcastMessage("startClick", com.lumoslabs.games.Game.TEST);
};
_local2.addListener(getController());
}
function createLevelSlider(width, height, numButtons, evaluate, calibrate) {
var level_slider;
var defaultDifficulty = difficultyLevel;
if (!(evaluate || (calibrate))) {
level_slider = com.lumoslabs.ui.LevelSlider(start_mc.attachMovie("level_slider_mc", "level_slider_mc", start_mc.getNextHighestDepth()));
level_slider._x = (width - level_slider._width) / 2;
level_slider._y = height - 150;
level_slider.setLevel(difficultyLevel);
}
var _local2 = start_mc.attachMovie("play_btn", "play_btn", start_mc.getNextHighestDepth());
_local2._x = (width / 2) + 80;
_local2._y = height - 190;
AsBroadcaster.initialize(_local2);
_local2.addListener(getController());
if (!(evaluate || (calibrate))) {
_local2.onRelease = function () {
this.broadcastMessage("startClick", level_slider.getCurrentLevel());
};
} else {
_local2.onRelease = function () {
this.broadcastMessage("startClick", defaultDifficulty);
};
}
var _local3 = start_mc.attachMovie("howTo_btn", "howTo_btn", start_mc.getNextHighestDepth());
_local3._x = (width / 2) - 80;
_local3._y = height - 190;
AsBroadcaster.initialize(_local3);
_local3.addListener(getController());
_local3.onRelease = function () {
this.broadcastMessage("helpClick");
};
}
function addStartScreen(target, depth, x, y, width, height, evaluate, calibrate) {
var _local2;
var _local3;
var _local4;
var _local7;
var _local12;
var _local11;
start_mc = target.createEmptyMovieClip("start", depth);
start_mc._x = x;
start_mc._y = y;
background_mc = start_mc.createEmptyMovieClip("background", 0);
background_mc.moveTo(0, 0);
background_mc.lineTo(width, 0);
background_mc.lineTo(width, height);
background_mc.lineTo(0, height);
background_mc.lineTo(0, 0);
instructionsContainer_mc = start_mc.attachMovie("notebook_cover_mc", "notebook_cover_mc", start_mc.getNextHighestDepth());
instructionsContainer_mc._x = Stage.width / 2;
instructionsContainer_mc._y = (Stage.height / 2) - 60;
_local4 = instructionsContainer_mc.instructions_txt;
if (calibrate) {
_local4.text = CALIBRATION_TXT + INSTRUCTIONS_TXT;
} else {
_local4.text = PRE_INSTRUCTIONS_TXT + INSTRUCTIONS_TXT;
}
start_mc.createTextField("start_text", start_mc.getNextHighestDepth(), 150, START_BTN_HEIGHT, 0, 0);
_local2 = start_mc.start_text;
_local2.autoSize = true;
_local2.textColor = 16777215 /* 0xFFFFFF */;
_local2.selectable = false;
_local2._visible = false;
_local3 = new TextFormat();
_local3.font = "Verdana";
_local3.size = 28;
_local2.setNewTextFormat(_local3);
_local2.text = DIFF_TXT;
background.showShade(true);
}
function defaultController(model) {
return(new com.lumoslabs.games.GameController(model, undefined));
}
function update(o, infoObj) {
var _local2;
if (infoObj instanceof com.lumoslabs.games.GameState) {
_local2 = com.lumoslabs.games.GameState(infoObj);
if (_local2.isRunning) {
destroy();
}
}
}
function destroy() {
background.showShade(false);
if ((start_mc == undefined) || (start_mc == null)) {
return(undefined);
}
delete controller;
start_mc.removeMovieClip();
model.removeObserver(this);
}
static var START_BTN_HEIGHT = (Stage.height / 2) + 100;
static var START_TXT = "Click to begin:";
static var DIFF_TXT = "Choose a Difficulty Level to Begin:";
static var PRE_INSTRUCTIONS_TXT = "Your goal is to collect as many birds as possible by spelling bird names. ";
static var INSTRUCTIONS_TXT = "Watch for a letter to briefly appear in the center of the screen. Simultaneously, a bird will appear in the scenery. Click in the location the bird appeared. If you get the location correct, you\u2019ll earn a chance to select the letter that appeared.";
static var CALIBRATION_TXT = "Click the play button to begin calibrating the game for your own personal visual attention abilities. ";
static var TEST_INSTRUCTIONS_TXT = "A letter and a small dot will flash on the screen. Click on the location of the dot, then select the letter that appeared.";
var numButtons = 10;
static var BTN_SIZE = 60;
static var BORDER = 60;
static var BUTTON = "difficulty_btn";
}
Symbol 343 MovieClip [__Packages.com.lumoslabs.ui.LevelSlider] Frame 0
class com.lumoslabs.ui.LevelSlider extends MovieClip
{
var slider_handle_mc, slider_handle, slider_label_tf, slider_label, segmentLength, _width, upperLimit, shadow, lowerLimit, _xmouse;
function LevelSlider () {
super();
slider_handle_mc = slider_handle;
slider_label_tf = slider_label;
segmentLength = _width / 10;
setLevel(1);
upperLimit = shadow._x;
lowerLimit = 10;
slider_handle_mc.onPress = com.lumoslabs.util.Delegate.create(this, pressToDrag);
slider_handle_mc.onRelease = com.lumoslabs.util.Delegate.create(this, release);
slider_handle_mc.onReleaseOutside = com.lumoslabs.util.Delegate.create(this, release);
slider_handle_mc.onMouseMove = com.lumoslabs.util.Delegate.create(this, onDrag);
}
function getCurrentLevel() {
return(getLevel(slider_handle_mc._x));
}
function setLevel(newLevel) {
var _local2 = shadow;
_local2._x = newLevel * segmentLength;
upperLimit = shadow._x;
_local2._width = (NUM_LEVELS * segmentLength) - _local2._x;
moveHandle(getLevelCenter(_local2._x - 1));
}
function pressToDrag() {
isGrabbed = true;
}
function onDrag() {
if (isGrabbed) {
var _local2 = _xmouse;
if (_local2 < lowerLimit) {
_local2 = lowerLimit;
} else if (_local2 > upperLimit) {
_local2 = upperLimit;
}
moveHandle(getLevelCenter(_local2));
}
}
function release() {
isGrabbed = false;
moveHandle(getLevelCenter(slider_handle_mc._x));
}
function moveHandle(xVal) {
slider_handle_mc._x = xVal;
slider_label_tf._x = xVal - LABEL_OFFSET;
slider_label_tf.text = getLevelLabel(xVal);
}
function getLevelLabel(xVal) {
return("Level " + getLevel(xVal));
}
function getLevel(xVal) {
return(Math.ceil(xVal / segmentLength));
}
function getLevelCenter(xVal) {
var _local2 = getLevel(xVal);
return(((_local2 - 1) + 0.5) * segmentLength);
}
var isGrabbed = false;
static var NUM_LEVELS = 10;
static var LABEL_OFFSET = 13;
}
Symbol 344 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdWatchingTestView] Frame 0
class com.lumoslabs.games.birdwatching.BirdWatchingTestView extends com.lumoslabs.games.GameView
{
var game_mc, letterSelect, getController, soundEffects, revertMouse, delayIntervalID, getModel, stimulus_mc, centralStimulus_txt, feedbackPos_mc, feedbackNeg_mc, transformMouse, central_mc;
function BirdWatchingTestView (gameModel, controller, target, depth, x, y, width, height) {
super(gameModel, controller, target, depth, x, y, width, height);
trace("width is " + width);
trace("game_mc._width is " + game_mc._width);
initStimulus(stimulusDepth);
initCentralView(centralTaskDepth);
trace("game_mc._width is " + game_mc._width);
letterSelect = new com.lumoslabs.games.birdwatching.BirdCaptureScreenTest(game_mc, com.lumoslabs.games.GameController(getController()), game_mc.getNextHighestDepth(), x, y, width, height);
soundEffects = new com.lumoslabs.games.birdwatching.BirdWatchingSounds();
trace("game_mc._width is " + game_mc._width);
}
function levelUp(level) {
super.levelUp(level);
revertMouse();
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.GameState) {
super.update(o, infoObj);
} else if (waitForEvent == true) {
eventQueue.push(infoObj);
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.StimulusEvent) {
fireStimulus(com.lumoslabs.games.birdwatching.StimulusEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.FeedbackEvent) {
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.LetterEvent) {
showLetterSelect(com.lumoslabs.games.birdwatching.LetterEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.BirdCaptureEvent) {
doLetterPick(com.lumoslabs.games.birdwatching.BirdCaptureEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.BadInputEvent) {
doTryAgain(com.lumoslabs.games.BadInputEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.birdwatching.SessionInfo) {
handleSessionData(com.lumoslabs.games.birdwatching.SessionInfo(infoObj));
} else {
super.update(o, infoObj);
}
}
function clearDelayInterval() {
clearInterval(delayIntervalID);
waitForEvent = false;
if (eventQueue.length > 0) {
update(getModel(), eventQueue.shift());
}
}
function clearStimulus() {
stimulus_mc._visible = false;
stimulus_mc._alpha = 100;
centralStimulus_txt.text = "";
clearDelayInterval();
}
function fireStimulus(stimulus) {
trace("displaying bird stimulus");
stimulus_mc._x = stimulus.x;
stimulus_mc._y = stimulus.y;
delayIntervalID = setInterval(this, "clearStimulus", stimulus.duration);
waitForEvent = true;
stimulus_mc._visible = true;
if (stimulus.useCentral) {
showCentralStimulus(stimulus.centralString);
}
}
function showCentralStimulus(birdLetter) {
trace("displaying central stimulus");
centralStimulus_txt.text = birdLetter.toUpperCase();
}
function showFeedback(feedback) {
var _local2;
if (feedback.isPositive) {
_local2 = feedbackPos_mc;
trace("it's positive");
} else {
_local2 = feedbackNeg_mc;
}
trace("feedback is " + _local2);
_local2._x = feedback.x;
_local2._y = feedback.y;
delayIntervalID = setInterval(this, "clearFeedback", feedback.duration, _local2);
waitForEvent = true;
_local2._visible = true;
stimulus_mc._visible = true;
if (!feedback.isPositive) {
stimulus_mc._alpha = 50;
}
soundEffects.playFeedbackSound();
}
function clearFeedback(feedback_mc) {
trace("clear feedback");
clearDelayInterval();
clearStimulus();
feedback_mc._visible = false;
}
function showLetterSelect(letterEvent) {
trace(letterEvent.letters);
revertMouse();
letterSelect.showLetters(letterEvent.letters);
}
function doLetterPick(captureEvent) {
letterSelect.doLetterPick(captureEvent);
if (captureEvent.isCaptured) {
delayIntervalID = setInterval(this, "doCapture", DELAY, captureEvent.birdName);
} else {
delayIntervalID = setInterval(this, "finalizeLetterScreen", DELAY);
}
}
function doCapture(name) {
if (letterSelect.isAnimating()) {
return(undefined);
}
clearDelayInterval();
letterSelect.doCapture(name);
delayIntervalID = setInterval(this, "finalizeLetterScreen", DELAY);
}
function doTryAgain() {
revertMouse();
letterSelect.doTryAgain();
}
function handleSessionData(responseInfo) {
trace("StimulusSessionInfo: errorData= " + responseInfo.errorDistanceArray);
var _local2;
_local2 = 0;
while (_local2 < responseInfo.eccentricityArray.length) {
trace(responseInfo.eccentricityArray[_local2]);
_local2++;
}
trace("eccentricityArray: " + responseInfo.eccentricityArray);
trace("average Error = " + responseInfo.averageError);
trace("letter response info = " + responseInfo.letterResponseArray);
trace("score = " + responseInfo.score);
if (responseInfo.endGame) {
revertMouse();
game_mc.unloadMovie();
}
}
function finalizeLetterScreen() {
if (letterSelect.isAnimating()) {
return(undefined);
}
clearDelayInterval();
letterSelect.finish();
}
function clearLetterScreen() {
letterSelect.clear();
transformMouse();
}
function initStimulus(depth) {
trace("initializing stimulus");
stimulus_mc = game_mc.attachMovie("circleStimulus", "stimulus", stimulusDepth);
stimulus_mc._x = 0;
stimulus_mc._y = 0;
stimulus_mc._visible = false;
}
function initCentralView(depth) {
var _local2;
central_mc = game_mc.attachMovie("centralBox_mc", "central_mc", depth);
central_mc._x = Stage.width / 2;
central_mc._y = Stage.height / 2;
central_mc.createTextField("centralStimulus_txt", 0, -20, -30, 0, 0);
centralStimulus_txt = central_mc.centralStimulus_txt;
centralStimulus_txt.autoSize = true;
_local2 = new TextFormat();
_local2.size = 50;
_local2.font = "Arial";
centralStimulus_txt.setNewTextFormat(_local2);
trace("text height is " + centralStimulus_txt.textHeight);
}
function loadStimulusImage(which) {
trace("loading stimulus image");
stimulus_mc.unloadMovie();
stimulus_mc = game_mc.attachMovie(String(stimuli[which % 3]), "stimulus", stimulusDepth);
}
var imagePath = "../resources/";
var backgrounds = new Array("background1.jpg", "background2.jpg", "background3.jpg");
var stimuli = new Array("bird1", "bird2", "bird3");
var waitForEvent = false;
var stimulusDepth = 10;
var feedbackDepth = 12;
var centralTaskDepth = 11;
var eventQueue = new Array();
var DELAY = 200;
}
Symbol 345 MovieClip [__Packages.com.lumoslabs.games.birdwatching.BirdCaptureScreenTest] Frame 0
class com.lumoslabs.games.birdwatching.BirdCaptureScreenTest
{
var controller, capture_mc, tweenListener, background_mc, nextButton, wrong_mc, sorry_txt, wordSpace, birdCage, pickButton, animationID;
function BirdCaptureScreenTest (target, controller, depth, x, y, width, height) {
this.controller = controller;
buildScreen(target, depth, x, y, width, height);
capture_mc._visible = false;
tweenListener = new Object();
tweenListener.onMotionFinished = com.lumoslabs.util.Delegate.create(this, doneAnimating);
}
function buildScreen(target, depth, x, y, width, height) {
capture_mc = target.createEmptyMovieClip("captureScreen", depth);
capture_mc._x = x;
capture_mc._y = y;
background_mc = capture_mc.createEmptyMovieClip("background", 0);
background_mc._alpha = 50;
background_mc.moveTo(0, 0);
background_mc.beginFill(16777215);
background_mc.lineTo(width, 0);
background_mc.lineTo(width, height);
background_mc.lineTo(0, height);
background_mc.lineTo(0, 0);
background_mc.endFill();
trace("loading buttons");
var _local2 = 0;
while (_local2 < numButtons) {
capture_mc.attachMovie("letter_btn_mc", BUTTON + _local2, _local2 + 1);
capture_mc[BUTTON + _local2]._x = ((BTN_SIZE + 20) * _local2) + 70;
capture_mc[BUTTON + _local2]._y = BTN_SIZE + 20;
capture_mc[BUTTON + _local2].button.enabled = false;
AsBroadcaster.initialize(capture_mc[BUTTON + _local2].button);
capture_mc[BUTTON + _local2].button.onRelease = function () {
this.broadcastMessage("letterClick", this._parent.button_txt.text);
this._parent.button.enabled = false;
};
capture_mc[BUTTON + _local2].button.addListener(controller);
_local2++;
}
nextButton = capture_mc.attachMovie("next_btn", "next_btn", capture_mc.getNextHighestDepth());
nextButton._x = Stage.width - 200;
nextButton._y = Stage.height - 100;
nextButton.enabled = false;
AsBroadcaster.initialize(nextButton);
nextButton.onRelease = function () {
this.broadcastMessage("nextClick");
};
nextButton.addListener(controller);
nextButton._visible = false;
wrong_mc = capture_mc.attachMovie("wrong_mc", "wrong", capture_mc.getNextHighestDepth());
wrong_mc._visible = false;
capture_mc.createTextField("sorry_txt", capture_mc.getNextHighestDepth(), width / 2, height / 3, 0, 0);
sorry_txt = capture_mc.sorry_txt;
sorry_txt.autoSize = "center";
sorry_txt.selectable = false;
sorry_txt.textColor = 16777215 /* 0xFFFFFF */;
var _local3 = new TextFormat();
_local3.bold = true;
_local3.font = "Arial";
_local3.size = 32;
sorry_txt.setNewTextFormat(_local3);
sorry_txt.text = TRY_AGAIN;
sorry_txt._visible = false;
}
function showLetters(letters) {
var _local3 = letters.length;
var _local2 = 0;
while (_local2 < _local3) {
capture_mc[BUTTON + _local2].button_txt.text = String(letters[_local2]);
capture_mc[BUTTON + _local2].button.enabled = true;
capture_mc[BUTTON + _local2]._alpha = 100;
capture_mc[BUTTON + _local2]._visible = true;
_local2++;
}
capture_mc._visible = true;
}
function show() {
capture_mc._visible = true;
}
function hide() {
capture_mc._visible = false;
}
function clear() {
wordSpace.hide();
birdCage.hide();
nextButton._visible = false;
nextButton.enabled = false;
sorry_txt._visible = false;
hide();
}
function doLetterPick(captureEvent) {
if (wordSpace == undefined) {
trace("height is " + capture_mc._height);
wordSpace = new com.lumoslabs.games.birdwatching.WordSpace(capture_mc, capture_mc.getNextHighestDepth(), capture_mc._width / 2, capture_mc._height - 200, captureEvent.birdName);
wordSpace.hide();
} else {
wordSpace.hide();
}
if (captureEvent.gotLetter) {
doCorrectPick(captureEvent.letter);
} else {
doIncorrectPick(captureEvent.letter);
}
}
function doCorrectPick(letter) {
trace(letter + " is correct!");
isolateButton(letter);
var _local4 = new mx.transitions.Tween(pickButton, "_width", mx.transitions.easing.Regular.easeOut, 80, 120, 1, true);
var _local3 = new mx.transitions.Tween(pickButton, "_height", mx.transitions.easing.Regular.easeOut, 80, 120, 1, true);
_local3.addListener(tweenListener);
animating = true;
wordSpace.addLetter(letter);
}
function doIncorrectPick(letter) {
trace(letter + " is wrong!");
isolateButton(letter);
wrong_mc._visible = true;
wrong_mc._x = pickButton._x - 10;
wrong_mc._y = pickButton._y - 10;
animating = true;
animationID = setInterval(this, "doneAnimating", 1000);
}
function doCapture(name) {
if (birdCage == undefined) {
birdCage = new com.lumoslabs.games.birdwatching.BirdCage(capture_mc, capture_mc.getNextHighestDepth(), 10, (capture_mc._height - com.lumoslabs.games.birdwatching.BirdCage.HEIGHT) / 2);
birdCage.hide();
} else {
birdCage.hide();
}
birdCage.addBird(name);
wordSpace.destroy();
delete wordSpace;
}
function doTryAgain() {
trace("showing try again");
sorry_txt._visible = true;
finish();
show();
}
function finish() {
resetButtons();
nextButton.enabled = true;
nextButton._visible = true;
}
function resetButtons() {
var _local2 = 0;
while (_local2 < numButtons) {
if (capture_mc[BUTTON + _local2]._visible) {
capture_mc[BUTTON + _local2]._visible = false;
}
_local2++;
}
pickButton._width = BTN_SIZE;
pickButton._height = BTN_SIZE;
pickButton._visible = false;
wrong_mc._visible = false;
}
function isolateButton(letter) {
var _local3 = 0;
var _local2 = 0;
while (_local2 < numButtons) {
if (letter != capture_mc[BUTTON + _local2].button_txt.text) {
com.lumoslabs.util.Animate.fadeMovie(capture_mc[BUTTON + _local2], 20);
} else {
_local3 = _local2;
}
_local2++;
}
pickButton = capture_mc[BUTTON + _local3];
}
function isAnimating() {
return(animating || (wordSpace.isAnimating()));
}
function doneAnimating() {
if (animationID != undefined) {
clearInterval(animationID);
animationID = undefined;
}
animating = false;
}
var numButtons = 5;
static var BUTTON = "letter_btn";
static var BTN_SIZE = 80;
var animating = false;
static var TRY_AGAIN = "Sorry, You Missed!";
}
Symbol 346 MovieClip [__Packages.com.lumoslabs.games.nback.NBackView] Frame 0
class com.lumoslabs.games.nback.NBackView extends com.lumoslabs.games.GameView
{
var help_mc, n, promo, version, soundEffects, timer, game_mc, score_mc, startScreen, getController, tweenManager, sIndex, stimuli, newPoints_mc, stimulusBox1_mc, width, height, stimulusBox2_mc, bonusBox_mc, pointsInterval, textFormat, keyListener, bonusText_mc, yes_btn, no_btn, neg_mc, pos_mc, interStimulusID, intervalID, testTime, bonusTime_mc, getModel;
function NBackView (gameModel, controller, target, depth, x, y, width, height, stimulus_type, promo) {
super(gameModel, controller, target, depth, x, y, width, height);
stageWidth = width;
stageHeight = height;
help_mc = com.lumoslabs.games.nback.MemoryMatchHelpScreen(target.attachMovie("help_mc", "help_mc", target.getNextHighestDepth(), {_x:0, _y:0}));
help_mc.init(this);
n = gameModel.getN();
this.promo = promo;
if ((stimulus_type != undefined) && (stimulus_type != "undefined")) {
version = stimulus_type;
} else if (n == 1) {
version = randomVersion();
} else if ((n = 3)) {
version = "concentricCircles";
} else {
version = "shapes";
}
initTextFormat();
buildView();
soundEffects = new com.lumoslabs.games.nback.NBackSounds(target);
timer = new com.lumoslabs.games.TimerDisplay(game_mc, game_mc.getNextHighestDepth(), 148, score_mc._y, stageWidth);
startScreen = new com.lumoslabs.games.nback.NBackStartScreen(gameModel, getController(), game_mc, game_mc.getNextHighestDepth(), x, y, stageWidth, stageHeight, promo);
tweenManager = new com.lumoslabs.util.TweenManager();
sIndex = -1;
stimuli = new Array();
}
function destroy() {
soundEffects.destroy();
}
function randomVersion() {
var _local1 = Math.random();
if (_local1 < 0.33) {
return("shapes");
}
if (_local1 < 0.66) {
return("characters");
}
return("concentricCircles");
}
function getSounds() {
return(com.lumoslabs.games.nback.NBackSounds(soundEffects));
}
function buildView() {
makeYesAndNoButtons();
buildStimuliDisplay();
game_mc.attachMovie("score_mc", "score_mc", game_mc.getNextHighestDepth());
score_mc = game_mc.score_mc;
score_mc._x = 318;
score_mc._y = 0;
game_mc.attachMovie("newPoints_mc", "newPoints_mc", game_mc.getNextHighestDepth());
newPoints_mc = game_mc.newPoints_mc;
newPoints_mc._visible = false;
newPoints_mc._x = stimulusBox1_mc._x;
newPoints_mc._y = stimulusBox1_mc._y - 125;
}
function buildStimuliDisplay() {
stimulusBox1_mc = game_mc.attachMovie("stimulusBox_mc", "stimulusBox1_mc", game_mc.getNextHighestDepth());
stimulusBox1_mc._x = (width * 3) / 4;
stimulusBox1_mc._y = (height / 2) - 60;
stimulusBox2_mc = game_mc.attachMovie("stimulusBox_mc", "stimulusBox2_mc", game_mc.getNextHighestDepth());
stimulusBox2_mc._x = width / 4;
stimulusBox2_mc._y = stimulusBox1_mc._y;
var _local2;
game_mc.attachMovie("prompt_mc", "prompt_mc", game_mc.getNextHighestDepth());
_local2 = game_mc.prompt_mc;
_local2._x = stageWidth / 2;
_local2._y = stimulusBox1_mc._y + 135;
game_mc.attachMovie("bonusBox_mc", "bonusBox_mc", game_mc.getNextHighestDepth());
bonusBox_mc = game_mc.bonusBox_mc;
bonusBox_mc._x = stimulusBox1_mc._x;
bonusBox_mc._y = stimulusBox1_mc._y;
bonusBox_mc._visible = false;
}
function updateScoreDisplay(gameState) {
score_mc.scoreValue_txt.text = gameState.score;
}
function displayNewPoints(gameState) {
if (gameState.newPoints == 0) {
return(undefined);
}
if ((gameState.score == 0) && (gameState.newPoints < 0)) {
return(undefined);
}
if (gameState.newPoints > 0) {
newPoints_mc.newPoints_txt.text = ("+" + gameState.newPoints) + "!";
} else {
newPoints_mc.newPoints_txt.text = gameState.newPoints;
}
newPoints_mc._visible = true;
if (pointsInterval != null) {
clearInterval(pointsInterval);
}
pointsInterval = setInterval(this, "hidePoints", 400);
}
function hidePoints() {
newPoints_mc._visible = false;
clearInterval(pointsInterval);
}
function initTextFormat() {
textFormat = new TextFormat();
textFormat.bold = true;
textFormat.font = "Arial Rounded MT Bold";
textFormat.size = 32;
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.nback.NEvent) {
doStimulus(com.lumoslabs.games.nback.NEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.GameState) {
updateScoreDisplay(com.lumoslabs.games.GameState(infoObj));
displayNewPoints(com.lumoslabs.games.GameState(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.FeedbackEvent) {
doFeedback(com.lumoslabs.games.FeedbackEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.BonusEvent) {
updateBonusText(com.lumoslabs.games.BonusEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.FinishEvent) {
keyListener.removeListener(getController());
showResults(com.lumoslabs.games.FinishEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.ResetEvent) {
reset();
} else if (infoObj instanceof com.lumoslabs.games.TimeEvent) {
updateTimer(com.lumoslabs.games.TimeEvent(infoObj));
} else if (infoObj instanceof com.lumoslabs.games.PauseEvent) {
togglePause();
} else if (infoObj instanceof com.lumoslabs.games.BonusTimeEvent) {
updateBonusTimer(com.lumoslabs.games.BonusTimeEvent(infoObj));
} else {
super.update(o, infoObj);
}
}
function reset() {
keyListener.addListener(getController());
sIndex = -1;
for (var _local2 in stimuli) {
stimuli[_local2].destroy();
}
bonusText_mc._visible = false;
newPoints_mc._visible = false;
bonusBox_mc._visible = false;
resetFeedback();
stimuli = new Array();
score_mc.scoreValue_txt.text = "0";
restartFade();
}
function revertButtons() {
yes_btn.gotoAndStop("_up");
no_btn.gotoAndStop("_up");
}
function doStimulus(event) {
if (stimuli.length <= event.numBack) {
for (var _local3 in stimuli) {
if (n == 1) {
com.lumoslabs.games.nback.NStimulus(stimuli[_local3]).getClip()._x = com.lumoslabs.games.nback.NStimulus(stimuli[_local3]).getClip()._x - (width / 2);
} else {
com.lumoslabs.games.nback.NStimulus(stimuli[_local3]).getClip()._x = com.lumoslabs.games.nback.NStimulus(stimuli[_local3]).getClip()._x - (width / 4);
}
}
stimuli.push(buildStimulus(event.id));
if (sIndex == event.numBack) {
}
} else {
if (game_mc.arrow2._visible) {
removeArrows();
}
var _local2 = event.numBack + 1;
fadeOut(com.lumoslabs.games.nback.NStimulus(stimuli[sIndex % _local2]), 1);
fadeOut(com.lumoslabs.games.nback.NStimulus(stimuli[(sIndex - 1) % _local2]), 2);
sIndex++;
stimuli[sIndex % _local2].setID(event.id);
fadeIn(stimuli[sIndex % _local2]);
}
}
function buildStimulus(id) {
sIndex = sIndex + 1;
var _local2 = new com.lumoslabs.games.nback.NStimulus(game_mc, stimulusSize, stimulusSize, "stimulus" + sIndex, version);
_local2.setID(id);
_local2.getClip()._x = stimulusBox1_mc._x;
_local2.getClip()._y = stimulusBox1_mc._y;
return(_local2);
}
function attachFeedbackGraphics() {
neg_mc = game_mc.attachMovie("feedback_neg_mc", "neg_mc", game_mc.getNextHighestDepth());
neg_mc._x = stimulusBox1_mc._x;
neg_mc._y = stimulusBox1_mc._y;
neg_mc._width = 80;
neg_mc._height = 80;
neg_mc._visible = false;
neg_mc._alpha = 70;
pos_mc = game_mc.attachMovie("feedback_pos_mc", "pos_mc", game_mc.getNextHighestDepth());
pos_mc._x = stimulusBox1_mc._x;
pos_mc._y = stimulusBox1_mc._y;
pos_mc._width = 80;
pos_mc._height = 80;
pos_mc._visible = false;
pos_mc._alpha = 70;
}
function addArrows() {
var _local2;
_local2 = game_mc.attachMovie("arrow", "arrow2", game_mc.getNextHighestDepth());
_local2._x = stimuli[sIndex].getClip()._x;
_local2._y = stimuli[sIndex].getClip()._y - 100;
}
function removeArrows() {
game_mc.arrow2.removeMovieClip();
}
function fadeIn(stimulus) {
clearInterval(interStimulusID);
var _local2 = stimulus.getClip();
_local2._visible = true;
tweenManager.addTween(new mx.transitions.Tween(_local2, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 10, false));
tweenManager.addTween(new mx.transitions.Tween(_local2, "_x", mx.transitions.easing.Regular.easeOut, stimulusBox1_mc._x + 100, stimulusBox1_mc._x, 10, false));
}
function fadeOut(stimulus, position) {
var _local2 = stimulus.getClip();
var _local3;
if (n == 1) {
_local3 = stimulusBox1_mc._x - stimulusBox2_mc._x;
if (numRight > 5) {
}
} else {
_local3 = (stimulusBox1_mc._x - stimulusBox2_mc._x) / 2;
}
tweenManager.addTween(new mx.transitions.Tween(_local2, "_x", mx.transitions.easing.Regular.easeOut, _local2._x, _local2._x - _local3, 10, false));
if (position == 1) {
tweenManager.addTween(new mx.transitions.Tween(_local2, "_alpha", mx.transitions.easing.Regular.easeOut, 100, alpha1, 6, false));
}
if (position == 2) {
tweenManager.addTween(new mx.transitions.Tween(_local2, "_alpha", mx.transitions.easing.Regular.easeOut, alpha1, alpha2, 10, false));
}
if (n == 1) {
if (alpha1 > 0) {
alpha1 = alpha1 - 4;
}
} else {
if (alpha1 > 0) {
alpha1 = alpha1 - 4;
}
if (alpha2 > 0) {
alpha2 = alpha2 - 3;
}
}
}
function restartFade() {
alpha1 = 16;
alpha2 = 12;
}
function doFeedback(event) {
if ((pos_mc == null) || (neg_mc == null)) {
attachFeedbackGraphics();
}
if (intervalID != null) {
hideFeedback();
}
testTime = getTimer();
numTries++;
if (event.isPositive) {
numRight++;
pos_mc._visible = true;
} else {
neg_mc._visible = true;
restartFade();
}
if (event.bonusUp) {
getSounds().playBonusSound();
} else {
getSounds().playFeedbackSound(event.isPositive);
}
intervalID = setInterval(this, "hideFeedback", feedbackDuration);
}
function updateBonusTimer(bonusTimeEvent) {
bonusTime_mc.bonusTime_txt.text = String(bonusTimeEvent.bonusTime);
if (bonusTimeEvent.bonusTime < 5) {
}
}
function updateBonusText(bonusEvent) {
if (bonusEvent.bonusFlag) {
bonusBox_mc._visible = true;
} else if (!bonusEvent.bonusFlag) {
getSounds().stopBonusSound();
bonusBox_mc._visible = false;
}
}
function hideFeedback() {
neg_mc._visible = false;
pos_mc._visible = false;
clearInterval(intervalID);
intervalID = null;
}
function resetFeedback() {
neg_mc.removeMovieClip();
pos_mc.removeMovieClip();
pos_mc = null;
neg_mc = null;
}
function updateTimer(timeEvent) {
timer.setTime(timeEvent.timeRemaining);
if ((timeEvent.timeRemaining < 8) && (!getSounds().getTimerSoundIsPlaying())) {
getSounds().playTimerSound();
}
}
function setupPlayToggle(playToggle) {
AsBroadcaster.initialize(playToggle);
playToggle.addListener(getController());
var myView = this;
playToggle.onPress = function () {
if (myView.togglePause()) {
this.broadcastMessage("togglePause");
this.gotoAndStop(2);
} else {
this.broadcastMessage("togglePlay");
this.gotoAndStop(1);
}
};
}
function togglePause() {
var _local2 = soundEffects.togglePause();
yes_btn.enabled = !_local2;
no_btn.enabled = !_local2;
showStimuli(!_local2);
if (_local2) {
Key.removeListener(keyListener);
} else {
Key.addListener(keyListener);
}
return(_local2);
}
function showStimuli(show) {
for (var _local3 in stimuli) {
stimuli[_local3].getClip()._visible = show;
}
}
function makeYesAndNoButtons() {
yes_btn = game_mc.attachMovie("yes_btn", "yes_btn", game_mc.getNextHighestDepth());
no_btn = game_mc.attachMovie("no_btn", "no_btn", game_mc.getNextHighestDepth());
no_btn._x = (stageWidth / 2) - (((yes_btn._width + no_btn._width) + 20) / 2);
no_btn._y = stageHeight - 80;
yes_btn._x = (stageWidth / 2) + 10;
yes_btn._y = no_btn._y;
AsBroadcaster.initialize(yes_btn);
yes_btn.onRelease = function () {
this.broadcastMessage("yesButton");
this.gotoAndStop(2);
};
yes_btn.onRollOver = function () {
this.gotoAndStop(2);
};
yes_btn.onRollOut = function () {
this.gotoAndStop(1);
};
yes_btn.addListener(getController());
AsBroadcaster.initialize(no_btn);
no_btn.onRelease = function () {
this.broadcastMessage("noButton");
this.gotoAndStop(2);
};
no_btn.addListener(getController());
no_btn.onRollOver = function () {
this.gotoAndStop(2);
};
no_btn.onRollOut = function () {
this.gotoAndStop(1);
};
keyListener = new Object();
AsBroadcaster.initialize(keyListener);
keyListener.onKeyDown = function () {
if (((Key.getCode() == 39) || (Key.getCode() == 89)) || (Key.getCode() == 187)) {
this.broadcastMessage("yesKey");
} else if (((Key.getCode() == 37) || (Key.getCode() == 78)) || (Key.getCode() == 189)) {
this.broadcastMessage("noKey");
}
};
keyListener.onKeyUp = function () {
this.broadcastMessage("onKeyUp");
};
Key.addListener(keyListener);
keyListener.addListener(getController());
}
function showResults(results) {
var _local4 = new com.lumoslabs.games.nback.NBackReplayScreen(com.lumoslabs.games.Game(getModel()), getController(), game_mc, game_mc.getNextHighestDepth(), stageWidth / 2, stageHeight / 2, results, width, height, promo);
getSounds().stopAllSounds();
var _local3 = 259;
var _local2 = 270;
numTries = 0;
numRight = 0;
}
function initMouse() {
}
function defaultController(model) {
return(new com.lumoslabs.games.nback.NBackController(model, this));
}
function keyPress(code) {
if (code == 39) {
yes_btn.gotoAndStop("_down");
}
if (code == 37) {
no_btn.gotoAndStop("_down");
}
}
function keyRelease(code) {
revertButtons();
}
function showDemo() {
super.showDemo();
keyListener.addListener(getController());
}
function endDemo() {
game_mc._visible = true;
com.lumoslabs.games.nback.NBackGame(getModel()).endHelp();
}
function getStimulusSize() {
return(stimulusSize);
}
function setStimulusSize(newSize) {
stimulusSize = newSize;
}
var stimulusSize = 75;
var mainSize = 24;
var feedbackDuration = 200;
var numTries = 0;
var numRight = 0;
var alpha1 = 32;
var alpha2 = 18;
static var oneBackText = "Is this number the same as the previous number?";
static var twoBackText = "Are the items in the boxes the same?";
static var threeBackText = "Is this the same as the number three places to the left?";
static var stageWidth = 640;
static var stageHeight = 480;
}
Symbol 347 MovieClip [__Packages.com.lumoslabs.util.TweenManager] Frame 0
class com.lumoslabs.util.TweenManager
{
var tweens;
function TweenManager () {
tweens = new Array();
}
function addTween(tween) {
tween.addListener(this);
tweens.push(tween);
animating = true;
}
function isAnimating() {
if (tweens.length > 0) {
return(true);
}
return(false);
}
function onMotionFinished() {
animating = false;
}
function destroy() {
}
var animating = false;
}
Symbol 348 MovieClip [__Packages.com.lumoslabs.games.TimerDisplay] Frame 0
class com.lumoslabs.games.TimerDisplay
{
var timer_mc, timeRemaining;
function TimerDisplay (target, depth, x, y, width) {
buildTimer(target, depth, x, y, width);
}
function buildTimer(target, depth, x, y, width) {
target.attachMovie("timer_mc", "timer_mc", depth);
timer_mc = target.timer_mc;
timer_mc._x = (width / 2) - timer_mc._width;
timer_mc._y = y;
timer_mc.timer_txt.text = "";
}
function setTime(timeRemaining) {
if (timeRemaining > 9) {
timer_mc.timer_txt.text = "0:" + String(timeRemaining);
} else {
timer_mc.timer_txt.text = "0:0" + String(timeRemaining);
}
}
function getTime() {
return(timeRemaining);
}
}
Symbol 349 MovieClip [__Packages.com.lumoslabs.games.nback.NBackStartScreen] Frame 0
class com.lumoslabs.games.nback.NBackStartScreen extends com.lumoslabs.util.AbstractView
{
var model, start_btn, start_mc, getController, controller;
function NBackStartScreen (gameModel, controller, target, depth, x, y, width, height, promo) {
super(gameModel, controller);
model.addObserver(this);
addStartScreen(target, depth, x, y, width, height, promo);
createStartButton(width, height, gameModel);
}
function createStartButton(width, height, game) {
start_btn = start_mc.attachMovie("start_btn", "start_btn", start_mc.getNextHighestDepth());
start_btn._y = height - 62;
start_btn._x = (width / 2) + 33;
AsBroadcaster.initialize(start_btn);
start_btn.onRelease = function () {
this.broadcastMessage("startClick", com.lumoslabs.games.Game.TEST);
};
start_btn.addListener(getController());
var _local2 = start_mc.attachMovie("howto_btn", "howto_btn", start_mc.getNextHighestDepth());
_local2._y = height - 62;
_local2._x = (width / 2) - 145;
_local2.onRelease = com.lumoslabs.util.Delegate.create(game, game.help);
var _local3 = start_mc.attachMovie("logo_loader_mc", "logo_loader_mc", start_mc.getNextHighestDepth());
}
function addStartScreen(target, depth, x, y, width, height, promo) {
if (promo) {
start_mc = target.attachMovie("promoStartScreen_mc", "startScreen_mc", depth, {_x:0, _y:0});
} else {
start_mc = target.attachMovie("startScreen_mc", "startScreen_mc", depth, {_x:0, _y:0});
}
}
function defaultController(model) {
return(new com.lumoslabs.games.nback.NBackController(model, undefined));
}
function update(o, infoObj) {
var _local2;
if (infoObj instanceof com.lumoslabs.games.GameState) {
_local2 = com.lumoslabs.games.GameState(infoObj);
if (_local2.isRunning) {
hide();
}
}
}
function hide() {
start_btn.removeListener(getController());
start_mc._visible = false;
model.removeObserver(this);
}
function show() {
start_btn.addListener(getController());
start_mc._visible = true;
model.addObserver(this);
}
function destroy() {
if ((start_mc == undefined) || (start_mc == null)) {
return(undefined);
}
delete controller;
start_mc.removeMovieClip();
model.removeObserver(this);
}
static var DIFF_TXT = "Choose a Difficulty Level to Begin:";
static var START_TXT = "Click to begin:";
static var NBACK_INSTRUCTIONS_TXT = "";
}
Symbol 350 MovieClip [__Packages.com.lumoslabs.games.nback.NBackController] Frame 0
class com.lumoslabs.games.nback.NBackController extends com.lumoslabs.util.AbstractController
{
var gameView, nBackView, game, getModel;
function NBackController (gameModel, gameView) {
super(gameModel);
this.gameView = gameView;
nBackView = com.lumoslabs.games.nback.NBackView(gameView);
game = com.lumoslabs.games.nback.NBackGame(getModel());
}
function yesButton() {
userButtonResponse(39);
}
function noButton() {
userButtonResponse(37);
}
function yesKey() {
userKeyResponse(39);
}
function noKey() {
userKeyResponse(37);
}
function userButtonResponse(code) {
if (code == 39) {
game.handleResponse(true);
} else if (code == 37) {
game.handleResponse(false);
} else {
game.handleMiscResponse(code);
}
nBackView.keyPress(code);
}
function userKeyResponse(code) {
if (code == 39) {
game.handleKeyResponse(true);
} else if (code == 37) {
game.handleKeyResponse(false);
} else {
game.handleMiscResponse(code);
}
nBackView.keyPress(code);
}
function onKeyUp(code) {
game.keyRelease();
nBackView.keyRelease(code);
}
function startClick() {
com.lumoslabs.games.Game(getModel()).start();
}
function restartClick() {
var _local2 = com.lumoslabs.games.Game(getModel());
_local2.restart();
}
function doneClick() {
com.lumoslabs.games.Game(getModel()).finalFinish();
}
function promoClick() {
com.lumoslabs.games.nback.NBackGame(getModel()).promo();
}
}
Symbol 351 MovieClip [__Packages.com.lumoslabs.games.nback.MemoryMatchHelpScreen] Frame 0
class com.lumoslabs.games.nback.MemoryMatchHelpScreen extends MovieClip
{
var _visible, view, yes_button, no_button, gotoAndPlay, stop, play_button, question_button, next_button, back_button;
function MemoryMatchHelpScreen () {
super();
_visible = false;
}
function init(view) {
this.view = view;
}
function initYesNoButtons() {
var owner = this;
yes_button.onRelease = function () {
owner.onYes();
};
no_button.onRelease = function () {
owner.onNo();
};
}
function showDemo() {
_visible = true;
Key.addListener(this);
doDemo("instructions");
}
function onKeyDown() {
if (((Key.getCode() == 39) || (Key.getCode() == 89)) || (Key.getCode() == 187)) {
onYes();
} else if (((Key.getCode() == 37) || (Key.getCode() == 78)) || (Key.getCode() == 189)) {
onNo();
}
}
function onYes() {
}
function onNo() {
}
function endDemo() {
_visible = false;
Key.removeListener(this);
view.endDemo();
}
function doDemo(helpLabel) {
gotoAndPlay(helpLabel);
var owner = this;
switch (helpLabel) {
case "instructions" :
stop();
onYes = function () {
};
onNo = function () {
};
play_button.onRelease = function () {
owner.endDemo();
};
question_button.onRelease = function () {
owner.doDemo("screen1");
};
next_button.onRelease = function () {
owner.doDemo("instructions2");
};
break;
case "instructions2" :
stop();
onYes = function () {
};
onNo = function () {
};
play_button.onRelease = function () {
owner.endDemo();
};
question_button.onRelease = function () {
owner.doDemo("screen1");
};
back_button.onRelease = function () {
owner.doDemo("instructions");
};
break;
case "screen1" :
onYes = function () {
owner.doDemo("screen1_right");
};
onNo = function () {
owner.doDemo("screen1_wrong");
};
initYesNoButtons();
break;
case "screen2" :
onYes = function () {
owner.doDemo("screen2_wrong");
};
onNo = function () {
owner.doDemo("screen2_right");
};
break;
case "screen3" :
onYes = function () {
owner.doDemo("screen3_wrong");
};
onNo = function () {
owner.doDemo("screen3_right");
};
break;
case "screen4" :
onYes = function () {
owner.doDemo("screen4_right");
};
onNo = function () {
owner.doDemo("screen4_wrong");
};
break;
case "screen4_right" :
stop();
onYes = function () {
};
onNo = function () {
};
play_button.onRelease = function () {
owner.endDemo();
};
question_button.onRelease = function () {
owner.doDemo("screen1");
};
break;
}
}
}
Symbol 352 MovieClip [__Packages.com.lumoslabs.games.nback.NBackSounds] Frame 0
class com.lumoslabs.games.nback.NBackSounds extends com.lumoslabs.games.SoundEffects
{
var ticker_mc, setPositiveFeedbackSound, addSound, setNegativeFeedbackSound, timerSound, bonusSound, ambientSound, stopAmbientSound, context_mc, volume, all_sounds;
function NBackSounds (target) {
super(target);
com.lumoslabs.games.SoundEffects.firstLoadedTarget.createEmptyMovieClip("ticker_mc", com.lumoslabs.games.SoundEffects.firstLoadedTarget.getNextHighestDepth());
ticker_mc = com.lumoslabs.games.SoundEffects.firstLoadedTarget.ticker_mc;
attachSounds();
}
function attachSounds() {
setPositiveFeedbackSound(addSound("correct.wav"));
setNegativeFeedbackSound(addSound("wrong.mp3"));
timerSound = addTicker(TICKER_ID);
bonusSound = addSound(BONUS_ID);
}
function destroy() {
stopAllSounds();
if (ambientSound) {
stopAmbientSound();
}
context_mc.removeMovieClip();
ticker_mc.removeMovieClip();
}
function addTicker(id) {
var _local2 = new com.lumoslabs.games.GameSound(ticker_mc);
_local2.attachSound(id);
_local2.setVolume(volume);
all_sounds.push(_local2);
return(_local2);
}
function playBonusSound() {
if (bonusSound.getPlay() == true) {
return(undefined);
}
bonusSound.start();
}
function stopBonusSound() {
bonusSound.stop(BONUS_ID);
}
function playTimerSound() {
timerSound.start(5, 1);
}
function stopTimerSound() {
timerSound.stop(TICKER_ID);
}
function getTimerSoundIsPlaying() {
return(timerSound.getPlay());
}
function getBonusIsPlaying() {
return(bonusSound.getPlay());
}
static var BONUS_ID = "bonus.mp3";
static var TICKER_ID = "metronome.mp3";
}
Symbol 353 MovieClip [__Packages.com.lumoslabs.games.nback.NStimulus] Frame 0
class com.lumoslabs.games.nback.NStimulus
{
var version, width, height, target, stim_mc, stim_txt, prevID;
function NStimulus (target, width, height, name, version, id) {
this.version = version;
buildStimulus(target, width, height, name);
this.width = width;
this.height = height;
this.target = target;
if (id != undefined) {
setID(id);
}
}
function buildStimulus(target, width, height, name) {
stim_mc = target.createEmptyMovieClip(name, target.getNextHighestDepth());
stim_mc._visible = true;
var _local2;
switch (version) {
case "shapes" :
_local2 = shapes;
break;
case "dominos" :
_local2 = dominos;
break;
case "characters" :
_local2 = characters;
break;
case "concentricCircles" :
_local2 = concentricCircles;
}
for (var _local3 in _local2) {
stim_mc.attachMovie(_local2[_local3], "symbol" + _local3, stim_mc.getNextHighestDepth());
stim_mc["symbol" + _local3]._visible = false;
}
var _local4 = new TextFormat();
_local4.bold = true;
_local4.font = "stimulus_font";
_local4.size = height;
stim_mc.createTextField("stim_txt", stim_mc.getNextHighestDepth(), 0, 0, 0, 0);
stim_txt = stim_mc.stime_txt;
stim_txt.embedFonts = true;
stim_txt.autoSize = "center";
stim_txt.textColor = 0;
stim_txt.selectable = false;
stim_txt.setNewTextFormat(_local4);
}
function setID(id) {
changeID(id);
}
function changeID(id) {
if (version == "numbers") {
if (id == 0) {
stim_txt.textColor = 16724787 /* 0xFF3333 */;
} else if (id == 1) {
stim_txt.textColor = 0;
} else {
stim_txt.textColor = 3355647 /* 0x3333FF */;
}
stim_txt.text = id.toString();
} else {
stim_mc["symbol" + prevID]._visible = false;
stim_mc["symbol" + id]._visible = true;
prevID = id;
}
}
function getClip() {
return(stim_mc);
}
function destroy() {
stim_mc.removeMovieClip();
}
var shapes = new Array("circle_mc", "square_mc", "triangle_mc");
var dominos = new Array("domino1_mc", "domino2_mc", "domino3_mc");
var characters = new Array("east_mc", "west_mc", "north_mc", "south_mc");
var concentricCircles = new Array("concCircle1_mc", "concCircle2_mc", "concCircle3_mc", "concCircle4_mc");
}
Symbol 354 MovieClip [__Packages.com.lumoslabs.games.nback.NBackReplayScreen] Frame 0
class com.lumoslabs.games.nback.NBackReplayScreen extends com.lumoslabs.util.AbstractView
{
var model, intervalID, textPosition, endScreen_mc, getController;
function NBackReplayScreen (gameModel, controller, target, depth, x, y, results, width, height, promo) {
super(gameModel, controller);
if (width != undefined) {
screenWidth = width;
}
if (height != undefined) {
screenHeight = height;
}
model.addObserver(this);
addReplayScreen(target, depth, x, y, results, promo);
if (promo) {
intervalID = setInterval(this, "createReplayButton", 1000);
} else {
intervalID = setInterval(this, "createDoneButton", 1000);
}
textPosition = 10;
}
function addReplayScreen(target, depth, x, y, results, promo) {
var _local8;
if (promo) {
endScreen_mc = target.attachMovie("promoEndScreen_mc", "endScreen_mc", target.getNextHighestDepth());
} else {
endScreen_mc = target.attachMovie("endScreen_mc", "endScreen_mc", target.getNextHighestDepth());
}
var _local3 = results.finalScoresArray.length - 1;
var _local4 = Math.round((results.numCorrect[_local3] / results.numTriesArray[_local3]) * 100);
if ((!isFinite(_local4)) || (isNaN(_local4))) {
_local4 = 0;
}
var _local6 = Math.round(results.time / results.numTriesArray[_local3]);
if (!isFinite(_local6)) {
_local6 = results.time;
}
var _local5 = Math.round((100 * results.afterErrorRight) / (results.afterErrorRight + results.afterErrorWrong));
if (isNaN(_local5)) {
_local5 = 0;
}
endScreen_mc.score_txt.text = (String(results.finalScoresArray[_local3]) + " ") + endScreen_mc.score_txt.text;
endScreen_mc.accuracy_txt.text = _local4 + "%";
endScreen_mc.correct_txt.text = results.numCorrect[_local3];
endScreen_mc.speed_txt.text = _local6 + "ms";
endScreen_mc.error_txt.text = _local5 + "%";
endScreen_mc.errorText_txt.text = getErrorText(_local5);
if (endScreen_mc.compareLink != undefined) {
AsBroadcaster.initialize(endScreen_mc.compareLink);
endScreen_mc.compareLink.onRelease = function () {
this.broadcastMessage("promoClick");
};
endScreen_mc.compareLink.addListener(getController());
}
}
function getErrorText(value) {
var _local1;
_local1 = 0;
while (_local1 < errorRanges.length) {
if (value >= errorRanges[_local1]) {
return(rangesText[_local1]);
}
_local1++;
}
return(rangesText[_local1]);
}
function createReplayButton() {
clearInterval(intervalID);
var _local2 = endScreen_mc.attachMovie("replay_btn", "replay_btn", endScreen_mc.getNextHighestDepth());
_local2._x = (screenWidth / 2) - (_local2._width / 2);
_local2._y = screenHeight - 62;
AsBroadcaster.initialize(_local2);
_local2.onRelease = function () {
this.broadcastMessage("doneClick");
};
_local2.addListener(getController());
}
function createDoneButton() {
clearInterval(intervalID);
var _local2 = endScreen_mc.attachMovie("done_btn", "done_btn", endScreen_mc.getNextHighestDepth());
_local2._x = (screenWidth / 2) - (_local2._width / 2);
_local2._y = screenHeight - 62;
AsBroadcaster.initialize(_local2);
_local2.onRelease = function () {
this.broadcastMessage("doneClick");
};
_local2.addListener(getController());
}
function defaultController(model) {
return(new com.lumoslabs.games.nback.NBackController(model, undefined));
}
function update(o, infoObj) {
if (infoObj instanceof com.lumoslabs.games.ResetEvent) {
destroy();
}
}
function destroy() {
endScreen_mc.removeMovieClip();
model.removeObserver(this);
}
static var GAME_END = "Game ";
static var SESSION_END = "Session Complete";
var screenWidth = 640;
var screenHeight = 480;
static var rangesText = ["Excellent!", "Great!", "Very good!", "Good!", "Fair"];
static var errorRanges = [90, 80, 70, 60];
}
Symbol 355 MovieClip [__Packages.com.lumoslabs.games.nback.speedmatch.SpeedMatchContainer] Frame 0
class com.lumoslabs.games.nback.speedmatch.SpeedMatchContainer extends com.lumoslabs.games.nback.NBackContainer
{
var width, height, _isPausable, setupContainerClip, model, game, view, container_mc;
function SpeedMatchContainer (target, depth, x, y) {
super(target, depth, x, y);
}
function setDefaults() {
width = 640;
height = 480;
_isPausable = true;
}
function initGame(params) {
var _local6 = 1;
var _local3 = 45;
var _local5;
var _local4 = false;
if (params.promo != undefined) {
_local4 = params.promo == true.toString();
} else {
trace("SpeedMatchContainer, no promo passed, default used: " + _local4);
}
if (params.time != undefined) {
_local3 = Number(params.time);
} else {
trace("SpeedMatchContainer, no time passed, default used: " + _local3);
}
if (params.stimulus_type != undefined) {
_local5 = params.stimulus_type;
} else {
trace("SpeedMatchContainer, no stimulus_type passed, random type used");
}
setupContainerClip();
model.clearObservers();
model = new com.lumoslabs.games.nback.NBackGame(_local6, _local3);
game = com.lumoslabs.games.Game(model);
view = new com.lumoslabs.games.nback.speedmatch.SpeedMatchView(model, undefined, container_mc, 0, 0, 0, width, height, _local5, _local4);
model.addObserver(view);
model.addObserver(this);
}
static function main() {
var _local2 = new com.lumoslabs.games.nback.speedmatch.SpeedMatchContainer(_root, 1, 0, 0);
}
}
Symbol 356 MovieClip [__Packages.com.lumoslabs.games.nback.speedmatch.SpeedMatchView] Frame 0
class com.lumoslabs.games.nback.speedmatch.SpeedMatchView extends com.lumoslabs.games.nback.NBackView
{
var help_mc, makeYesAndNoButtons, yes_btn, no_btn, game_mc, score_mc, width, newPoints_mc, stimulusBox1_mc, height, prompt_mc, bonusBox_mc, sIndex, stimuli, goListener, go_btn, tweenManager, interStimulusID, stimulusSize, version, getController;
function SpeedMatchView (gameModel, controller, target, depth, x, y, width, height, stimulus_type, promo) {
super(gameModel, controller, target, depth, x, y, width, height, stimulus_type, promo);
help_mc = com.lumoslabs.games.nback.speedmatch.SpeedMatchHelpScreen(target.attachMovie("help_mc", "help_mc", target.getNextHighestDepth(), {_x:0, _y:0}));
help_mc.init(this);
}
function buildView() {
makeGoButton();
makeYesAndNoButtons();
yes_btn._visible = false;
no_btn._visible = false;
buildStimuliDisplay();
game_mc.attachMovie("score_mc", "score_mc", game_mc.getNextHighestDepth());
score_mc = game_mc.score_mc;
score_mc._x = (width / 2) - 2;
score_mc._y = 0;
game_mc.attachMovie("newPoints_mc", "newPoints_mc", game_mc.getNextHighestDepth());
newPoints_mc = game_mc.newPoints_mc;
newPoints_mc._visible = false;
newPoints_mc._x = stimulusBox1_mc._x;
newPoints_mc._y = stimulusBox1_mc._y - (stimulusBox1_mc._width / 2);
}
function buildStimuliDisplay() {
stimulusBox1_mc = game_mc.attachMovie("stimulus_container_mc", "stimulusBox1_mc", game_mc.getNextHighestDepth());
stimulusBox1_mc._x = width / 2;
stimulusBox1_mc._y = (height / 2) - 40;
prompt_mc = game_mc.attachMovie("prompt_mc", "prompt_mc", game_mc.getNextHighestDepth());
prompt_mc._x = width / 2;
prompt_mc._y = stimulusBox1_mc._y + 155;
prompt_mc.gotoAndStop("go");
bonusBox_mc = stimulusBox1_mc.box_mc.attachMovie("bonus_box_large_mc", "bonusBox_mc", game_mc.getNextHighestDepth());
bonusBox_mc._visible = false;
}
function doStimulus(event) {
var _local2 = 2;
fadeOut(com.lumoslabs.games.nback.NStimulus(stimuli[sIndex % _local2]), 1);
if (stimuli.length < _local2) {
if (stimuli.length == 0) {
Key.addListener(goListener);
go_btn._visible = true;
}
if (stimuli.length == 1) {
go_btn._visible = false;
yes_btn._visible = true;
no_btn._visible = true;
prompt_mc.gotoAndStop("ask");
}
stimuli.push(buildStimulus(event.id));
} else {
sIndex++;
stimuli[sIndex % _local2].setID(event.id);
}
fadeIn(stimuli[sIndex % _local2]);
}
function fadeOut(stimulus, position) {
var _local2 = stimulus.getClip();
var _local3 = fadeDistance;
tweenManager.addTween(new mx.transitions.Tween(_local2, "_alpha", mx.transitions.easing.Regular.easeOut, 100, 0, 4, false));
tweenManager.addTween(new mx.transitions.Tween(_local2, "_x", mx.transitions.easing.Regular.easeOut, _local2._x, _local2._x - _local3, 4, false));
}
function fadeIn(stimulus) {
clearInterval(interStimulusID);
var _local2 = stimulus.getClip();
_local2._visible = true;
tweenManager.addTween(new mx.transitions.Tween(_local2, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 3, false));
tweenManager.addTween(new mx.transitions.Tween(_local2, "_x", mx.transitions.easing.Regular.easeOut, fadeDistance, 0, 4, false));
}
function buildStimulus(id) {
sIndex = sIndex + 1;
var _local2 = new com.lumoslabs.games.nback.NStimulus(stimulusBox1_mc.panel_mc, stimulusSize, stimulusSize, "stimulus" + sIndex, version);
_local2.setID(id);
return(_local2);
}
function makeGoButton() {
go_btn = game_mc.attachMovie("go_btn", "go_btn", game_mc.getNextHighestDepth());
go_btn._visible = false;
go_btn._x = (width / 2) - (go_btn._width / 2);
go_btn._y = height - 60;
AsBroadcaster.initialize(go_btn);
var goMC = go_btn;
goListener = new Object();
goListener.onKeyDown = function () {
Key.removeListener(this);
if (!((((((Key.getCode() == 39) || (Key.getCode() == 89)) || (Key.getCode() == 187)) || (Key.getCode() == 37)) || (Key.getCode() == 78)) || (Key.getCode() == 189))) {
goMC.broadcastMessage("yesButton");
}
};
var goLis = goListener;
go_btn.onRelease = function () {
Key.removeListener(goLis);
this.broadcastMessage("yesButton");
this.gotoAndStop(2);
};
go_btn.onRollOver = function () {
this.gotoAndStop(2);
};
go_btn.onRollOut = function () {
this.gotoAndStop(1);
};
go_btn.addListener(getController());
}
function togglePause() {
go_btn.enabled = !go_btn.enabled;
return(super.togglePause());
}
function reset() {
super.reset();
yes_btn._visible = false;
no_btn._visible = false;
}
var fadeDistance = 100;
}
Symbol 357 MovieClip [__Packages.com.lumoslabs.games.nback.speedmatch.SpeedMatchHelpScreen] Frame 0
class com.lumoslabs.games.nback.speedmatch.SpeedMatchHelpScreen extends MovieClip
{
var _visible, view, gotoAndStop;
function SpeedMatchHelpScreen () {
super();
_visible = false;
}
function init(view) {
this.view = view;
}
function showDemo() {
_visible = true;
Key.addListener(this);
gotoAndStop("instructions");
}
function onKeyDown() {
onAnyKey();
if (((Key.getCode() == 39) || (Key.getCode() == 89)) || (Key.getCode() == 187)) {
onYes();
} else if (((Key.getCode() == 37) || (Key.getCode() == 78)) || (Key.getCode() == 189)) {
onNo();
}
}
function onAnyKey() {
}
function onYes() {
}
function onNo() {
}
function endDemo() {
_visible = false;
Key.removeListener(this);
view.endDemo();
}
}
Symbol 358 MovieClip [__Packages.mx.transitions.easing.None] Frame 0
class mx.transitions.easing.None
{
function None () {
}
static function easeNone(t, b, c, d) {
return(((c * t) / d) + b);
}
static function easeIn(t, b, c, d) {
return(((c * t) / d) + b);
}
static function easeOut(t, b, c, d) {
return(((c * t) / d) + b);
}
static function easeInOut(t, b, c, d) {
return(((c * t) / d) + b);
}
static var version = "1.1.0.52";
}