Section 1
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 2
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 3
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 4
//ExtendedSound (uk.co.stdio.sound.ExtendedSound)
package uk.co.stdio.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ExtendedSound extends Sound {
protected var fadeStartVolume:Number;
protected var fadeEndVolume:Number;
protected var panStartPosition:Number;
protected var panDuration:Number;
protected var panEndPosition:Number;
protected var masterVolume:Number;// = 1
protected var fadeTimer:Timer;
protected var panTimer:Timer;
protected var fadeDuration:Number;
protected var panStartTime:Number;
protected var fadeStartTime:Number;
protected var soundChannel:SoundChannel;
private static const TIMER_UPDATE_RATE:Number = 20;
public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{
fadeStartVolume = Math.max(0, Math.min(1, _arg1));
soundChannel = super.play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume)));
if (_arg3 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg3;
fadeEndVolume = Math.max(0, Math.min(1, _arg2));
startFade();
};
return (soundChannel);
}
public function stop():void{
if (soundChannel != null){
soundChannel.stop();
};
}
public function fadeOut(_arg1:Number=0):void{
if (_arg1 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg1;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = 0;
startFade();
} else {
stop();
};
}
protected function stopPan():void{
if (((!((panTimer == null))) && (panTimer.running))){
panTimer.reset();
};
}
protected function startPan():void{
if (panTimer == null){
panTimer = new Timer(TIMER_UPDATE_RATE);
panTimer.addEventListener(TimerEvent.TIMER, updatePan);
};
stopPan();
panTimer.start();
}
public function setPan(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(-1, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local2, _arg1);
stopPan();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:Number;
masterVolume = Math.max(0, Math.min(1, _arg1));
if (soundChannel != null){
_local2 = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_arg1 * masterVolume), _local2);
};
}
protected function stopFade():void{
if (((!((fadeTimer == null))) && (fadeTimer.running))){
fadeTimer.reset();
};
}
public function getSoundChannel():SoundChannel{
return (soundChannel);
}
public function setVolume(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(0, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_arg1 * masterVolume), _local2);
stopFade();
};
}
override public function toString():String{
var _local1:String = getQualifiedClassName(this);
if (soundChannel != null){
_local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]"));
_local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]"));
};
return (_local1);
}
protected function updatePan(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - panStartTime) / panDuration);
if (_local3 >= 1){
stopPan();
_local2 = panEndPosition;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition);
};
};
var _local4:Number = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local4, _local2);
}
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
if (_arg3 != null){
_arg3.volume = (_arg3.volume * masterVolume);
} else {
_arg3 = new SoundTransform(masterVolume);
};
soundChannel = super.play(_arg1, _arg2, _arg3);
return (soundChannel);
}
protected function updateFade(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration);
if (_local3 >= 1){
stopFade();
_local2 = fadeEndVolume;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume);
};
};
var _local4:Number = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_local2 * masterVolume), _local4);
}
protected function startFade():void{
if (fadeTimer == null){
fadeTimer = new Timer(TIMER_UPDATE_RATE);
fadeTimer.addEventListener(TimerEvent.TIMER, updateFade);
};
stopFade();
fadeTimer.start();
}
public function panTo(_arg1:Number, _arg2:Number):void{
if (_arg2 > 0){
panStartTime = getTimer();
panDuration = _arg2;
panStartPosition = soundChannel.soundTransform.pan;
panEndPosition = _arg1;
startPan();
} else {
setPan(_arg1);
};
}
}
}//package uk.co.stdio.sound
Section 5
//SoundManager (uk.co.stdio.sound.SoundManager)
package uk.co.stdio.sound {
public class SoundManager {
private var sounds:Array;
private var prevMasterVolume:Number;
private var muteState:Boolean;// = false
private var id:String;
private var masterVolume:Number;// = 1
private static var instanceList:Array = new Array();
private static var muted:Boolean = false;
public function SoundManager(_arg1:String=""){
prevMasterVolume = masterVolume;
sounds = new Array();
super();
this.id = _arg1;
instanceList.push(this);
}
public function stopAllSounds():void{
var _local1:String;
for (_local1 in sounds) {
sounds[_local1].stop();
};
}
public function getSoundFromID(_arg1:String):ExtendedSound{
return (sounds[_arg1]);
}
public function get muted():Boolean{
return (muteState);
}
public function registerSound(_arg1:ExtendedSound, _arg2:String):void{
if (sounds[_arg2] != null){
throw (new Error((((("ID conflict: A sound with the id[" + _arg2) + "] already exists in SoundManager[") + this.id) + "]'s sound list.")));
};
sounds[_arg2] = _arg1;
_arg1.setMasterVolume(masterVolume);
}
public function setMasterVolume(_arg1:Number):void{
var _local2:String;
prevMasterVolume = masterVolume;
masterVolume = Math.max(0, Math.min(1, _arg1));
for (_local2 in sounds) {
sounds[_local2].setMasterVolume(masterVolume);
};
}
public function toString():String{
var _local2:String;
var _local1 = "====================\n";
_local1 = (_local1 + (("SoundManager [" + id) + "]\n"));
_local1 = (_local1 + "--------------------\n");
_local1 = (_local1 + (("master vol[" + masterVolume) + "]\n"));
_local1 = (_local1 + "--------------------");
for (_local2 in sounds) {
_local1 = (_local1 + ("\n" + sounds[_local2].toString()));
};
_local1 = (_local1 + "\n====================");
return (_local1);
}
public function unmute():void{
muteState = false;
setMasterVolume(prevMasterVolume);
}
public function mute():void{
muteState = true;
setMasterVolume(0);
}
public static function isGloballyMuted():Boolean{
return (muted);
}
public static function globalUnmute():void{
var _local1:int;
while (_local1 < instanceList.length) {
instanceList[_local1].unmute();
_local1++;
};
muted = false;
}
public static function globalMute():void{
var _local1:int;
while (_local1 < instanceList.length) {
instanceList[_local1].mute();
_local1++;
};
muted = true;
}
}
}//package uk.co.stdio.sound
Section 6
//LampGame (uk.kerb.calumBest.game.LampGame)
package uk.kerb.calumBest.game {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.game.*;
import uk.kerb.calumBest.*;
import flash.utils.*;
import uk.kerb.utils.ui.*;
import flash.ui.*;
import flash.geom.*;
public class LampGame extends Sprite implements IDisposable {
private var decayRate:Number;
public var renderer:Renderer;
private var bulbs:Array;
private var disabled:Boolean;
private var hit:Boolean;
private var kc:KeyControl;
private var numSnakes:int;
private var currBulbX:int;
private var currBulbY:int;
private var userTrails:Array;
private var extraSnakes:int;
private var keyTimer:Timer;
private var snakeSpeed:Number;
private var userLife:Number;
public var playSFX:Boolean;// = true
private var snakes:Array;
public var userControlled:Boolean;
private static const USER_TRAIL_LENGTH:int = 5;
private static const INIT_LIFE:Number = 50;
private static const KEY_TIMER_INTERVAL:int = 100;
public static var COLS:int = 20;
public static var ROWS:int = 4;
public function LampGame(_arg1:int, _arg2:int, _arg3:Number, _arg4:Number, _arg5:int=20, _arg6:int=4){
this.numSnakes = _arg1;
this.extraSnakes = _arg2;
this.snakeSpeed = _arg3;
this.decayRate = _arg4;
COLS = _arg5;
ROWS = _arg6;
init();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
public function start():void{
if (!disabled){
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.focus = stage;
keyTimer.start();
};
}
public function stop():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
keyTimer.stop();
}
private function init():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:Snake;
userLife = INIT_LIFE;
userControlled = true;
disabled = false;
bulbs = new Array();
_local3 = 0;
while (_local3 < ROWS) {
bulbs.push(new Array());
_local2 = 0;
while (_local2 < COLS) {
bulbs[_local3].push(0);
_local2++;
};
_local3++;
};
userTrails = new Array();
currBulbX = (0.5 * COLS);
currBulbY = (0.5 * ROWS);
snakes = new Array();
_local1 = 0;
while (_local1 < numSnakes) {
do {
_local2 = (Math.random() * COLS);
_local3 = (Math.random() * ROWS);
} while ((((_local2 == currBulbX)) && ((_local3 == currBulbY))));
snakes.push(new Snake(_local2, _local3, snakeSpeed));
bulbs[_local3][_local2] = 1;
_local1++;
};
if ((((extraSnakes == 1)) || ((extraSnakes == 3)))){
_local4 = new Snake(0, 0, snakeSpeed);
_local4.vx = snakeSpeed;
_local4.vy = 0;
snakes.push(_local4);
bulbs[0][0] = 1;
_local4 = new Snake((COLS - 1), (ROWS - 1), snakeSpeed);
_local4.vx = -(snakeSpeed);
_local4.vy = 0;
snakes.push(_local4);
bulbs[(ROWS - 1)][(COLS - 1)] = 1;
};
if ((((extraSnakes == 2)) || ((extraSnakes == 3)))){
_local4 = new Snake(0, 0, snakeSpeed);
_local4.vx = 0;
_local4.vy = snakeSpeed;
snakes.push(_local4);
bulbs[0][0] = 1;
_local4 = new Snake((COLS - 1), (ROWS - 1), snakeSpeed);
_local4.vx = 0;
_local4.vy = -(snakeSpeed);
snakes.push(_local4);
bulbs[(ROWS - 1)][(COLS - 1)] = 1;
};
renderer = new Renderer(10, 310);
addChild(renderer);
kc = KeyControl.getInstance();
keyTimer = new Timer(KEY_TIMER_INTERVAL);
keyTimer.addEventListener(TimerEvent.TIMER, onKeyTimer);
}
public function dispose():void{
stop();
renderer.drawEmpty();
removeChild(renderer);
keyTimer.removeEventListener(TimerEvent.TIMER, onKeyTimer);
}
public function disable():void{
renderer.drawEmpty();
disabled = true;
stop();
renderer.drawEmpty();
keyTimer.removeEventListener(TimerEvent.TIMER, onKeyTimer);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
kc.init(stage);
stage.focus = stage;
renderer.drawEmpty();
}
private function onKeyTimer(_arg1:TimerEvent):void{
if (userControlled){
if (kc.keyIsDown(Keyboard.LEFT)){
currBulbX--;
};
if (kc.keyIsDown(Keyboard.RIGHT)){
currBulbX++;
};
if (kc.keyIsDown(Keyboard.UP)){
currBulbY--;
};
if (kc.keyIsDown(Keyboard.DOWN)){
currBulbY++;
};
if (currBulbX == -1){
currBulbX++;
} else {
if (currBulbX == COLS){
currBulbX--;
};
};
if (currBulbY == -1){
currBulbY++;
} else {
if (currBulbY == ROWS){
currBulbY--;
};
};
};
}
private function onEnterFrame(_arg1:Event):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Snake;
_local2 = 0;
while (_local2 < snakes.length) {
_local5 = snakes[_local2];
_local5.step();
_local3 = _local5.x;
_local4 = _local5.y;
bulbs[_local4][_local3] = 1;
_local2++;
};
_local4 = 0;
while (_local4 < ROWS) {
_local3 = 0;
while (_local3 < COLS) {
bulbs[_local4][_local3] = (bulbs[_local4][_local3] * decayRate);
if (bulbs[_local4][_local3] < 0.1){
bulbs[_local4][_local3] = 0;
};
_local3++;
};
_local4++;
};
userTrails.push(new Point(currBulbX, currBulbY));
if (userTrails.length > USER_TRAIL_LENGTH){
userTrails.shift();
};
if (((((playSFX) && (!(hit)))) && ((bulbs[currBulbY][currBulbX] > 0.1)))){
Main.smSFX.getSoundFromID("HitSound").play();
};
hit = (bulbs[currBulbY][currBulbX] > 0.1);
userLife = (userLife - bulbs[currBulbY][currBulbX]);
if (userLife < 0){
gameOver();
};
renderer.draw(bulbs, userTrails, (userLife / INIT_LIFE), bulbs[currBulbY][currBulbX]);
}
private function gameOver():void{
dispatchEvent(new Event(Level.EVENT_LOSE_LEVEL));
}
}
}//package uk.kerb.calumBest.game
Section 7
//Renderer (uk.kerb.calumBest.game.Renderer)
package uk.kerb.calumBest.game {
import flash.display.*;
import uk.kerb.utils.game.*;
import flash.filters.*;
public class Renderer extends Sprite {
public var energyMeter:MovieClip;
public var COL_WIDTH:Number;// = 18.5
public var BULB_RADIUS:Number;// = 8.75
public var ROW_HEIGHT:Number;// = 18
private var lights:Sprite;
private static const USER_COLOUR:uint = 16755971;
private static const SNAKE_COLOUR:uint = 15467392;
public function Renderer(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
lights = new Sprite();
var _local3:BevelFilter = new BevelFilter(2, 45, 0xFFFFFF, 1, 0, 1, 3, 3, 0.4);
var _local4:GlowFilter = new GlowFilter(0, 1, 5, 5, 0.3);
lights.filters = [_local3, _local4];
addChild(lights);
energyMeter = (Main.assetFactory.createDisplayObject("EnergyMeterAsset") as MovieClip);
energyMeter.gotoAndStop(energyMeter.totalFrames);
energyMeter.scaleX = 0.522;
energyMeter.scaleY = 0.522;
energyMeter.x = 383;
energyMeter.y = 2;
addChild(energyMeter);
}
private function drawBulbAt(_arg1:Number, _arg2:Number, _arg3:uint, _arg4:Number):void{
_arg1 = (_arg1 + (0.5 * ROW_HEIGHT));
_arg2 = (_arg2 + (0.5 * COL_WIDTH));
lights.graphics.moveTo(_arg1, _arg2);
lights.graphics.beginFill(_arg3, _arg4);
lights.graphics.drawCircle(_arg1, _arg2, BULB_RADIUS);
lights.graphics.endFill();
}
public function draw(_arg1:Array, _arg2:Array, _arg3:Number, _arg4:Number):void{
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:Number;
var _local9:Number;
var _local10:Number;
lights.graphics.clear();
_local6 = 0;
while (_local6 < LampGame.ROWS) {
_local5 = 0;
while (_local5 < LampGame.COLS) {
drawBulbAt((_local5 * COL_WIDTH), (_local6 * ROW_HEIGHT), 0xFFFFFF, 1);
drawBulbAt((_local5 * COL_WIDTH), (_local6 * ROW_HEIGHT), SNAKE_COLOUR, _arg1[_local6][_local5]);
_local5++;
};
_local6++;
};
_local7 = 0;
while (_local7 < _arg2.length) {
_local8 = (_local7 / _arg2.length);
drawBulbAt((_arg2[_local7].x * COL_WIDTH), (_arg2[_local7].y * ROW_HEIGHT), USER_COLOUR, _local8);
_local7++;
};
if (_arg4 > 0){
_local9 = ((_arg2[(_arg2.length - 1)].x * COL_WIDTH) + (0.5 * COL_WIDTH));
_local10 = ((_arg2[(_arg2.length - 1)].y * ROW_HEIGHT) + (0.5 * ROW_HEIGHT));
_arg4 = (_arg4 * 10);
_arg4 = (_arg4 + 13);
lights.graphics.lineStyle(5, USER_COLOUR);
lights.graphics.moveTo(_local9, _local10);
lights.graphics.drawCircle(_local9, _local10, _arg4);
lights.graphics.endFill();
};
energyMeter.gotoAndStop(int((energyMeter.totalFrames * _arg3)));
}
public function drawEmpty():void{
var _local1:int;
var _local2:int;
_local2 = 0;
while (_local2 < LampGame.ROWS) {
_local1 = 0;
while (_local1 < LampGame.COLS) {
drawBulbAt((_local1 * COL_WIDTH), (_local2 * ROW_HEIGHT), 0xFFFFFF, 1);
_local1++;
};
_local2++;
};
}
}
}//package uk.kerb.calumBest.game
Section 8
//Snake (uk.kerb.calumBest.game.Snake)
package uk.kerb.calumBest.game {
public class Snake {
private var yMin:Number;
public var vx:Number;
public var vy:Number;
private var yMax:Number;
private var xMax:Number;
public var x:Number;
public var y:Number;
private var xMin:Number;
public function Snake(_arg1:int, _arg2:int, _arg3:Number){
this.x = _arg1;
this.y = _arg2;
init(_arg3);
}
private function init(_arg1:Number):void{
xMin = 0;
xMax = (LampGame.COLS - 1);
yMin = 0;
yMax = (LampGame.ROWS - 1);
var _local2:Number = (0.25 * Math.PI);
var _local3:Number = ((Math.random() * 0.2) - 0.1);
_local2 = (_local2 + _local3);
if (Math.random() < 0.5){
_local2 = -(_local2);
if (Math.random() < 0.5){
_local2 = (_local2 - 0.5);
};
} else {
if (Math.random() < 0.5){
_local2 = (_local2 + 0.5);
};
};
vx = (_arg1 * Math.cos(_local2));
vy = (_arg1 * Math.sin(_local2));
}
public function step():void{
x = (x + vx);
y = (y + vy);
if (x < xMin){
x = xMin;
vx = -(vx);
} else {
if (x > xMax){
x = xMax;
vx = -(vx);
};
};
if (y < yMin){
y = yMin;
vy = -(vy);
} else {
if (y > yMax){
y = yMax;
vy = -(vy);
};
};
}
}
}//package uk.kerb.calumBest.game
Section 9
//Constants (uk.kerb.calumBest.Constants)
package uk.kerb.calumBest {
public class Constants {
public static const LOSE_VIDEO_URL:String = "http://akamai.mtv.co.uk/www/calum_best/LOSE.flv";
public static const VIDEO_URLS:Array = ["http://akamai.mtv.co.uk/www/calum_best/LEVEL1.flv", "http://akamai.mtv.co.uk/www/calum_best/LEVEL2.flv", "http://akamai.mtv.co.uk/www/calum_best/LEVEL3.flv", "http://akamai.mtv.co.uk/www/calum_best/LEVEL4.flv"];
public static const DISTRACTION_CODE:String = "1200hours";
public static const WIN_VIDEO_URL:String = "http://akamai.mtv.co.uk/www/calum_best/WIN.flv";
}
}//package uk.kerb.calumBest
Section 10
//Game (uk.kerb.calumBest.Game)
package uk.kerb.calumBest {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.game.*;
import flash.utils.*;
import uk.kerb.tracking.*;
import flash.ui.*;
import flash.text.*;
public class Game extends AbstractSection {
private var currLevelThumb:MovieClip;
private var gameDisabled:Boolean;
private var level:Level;
private var numLevels:int;
private var levelStarted:Boolean;
private var levelPanel:MovieClip;
private var panelTimer:Timer;
private var distractionPanel:MovieClip;
private var currLevel:int;
private function closeDistractionPanel():void{
distractionPanel.close_btn.removeEventListener(MouseEvent.CLICK, onDistractionPanelClose);
distractionPanel.link_btn.removeEventListener(MouseEvent.CLICK, onDistractionPanelLink);
distractionPanel.submit_btn.removeEventListener(MouseEvent.CLICK, onDistractionPanelSubmit);
distractionPanel.logo_btn.removeEventListener(MouseEvent.CLICK, onLevelPanelMTVClick);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onDistractionPanelKeyDown);
removeChild(distractionPanel);
if (level){
if (gameDisabled){
level.disableGame();
};
level.unpause();
};
}
private function onLevelPanelEnterFrame(_arg1:Event):void{
if (levelPanel.logo_btn){
levelPanel.logo_btn.addEventListener(MouseEvent.CLICK, onLevelPanelMTVClick);
level.removeEventListener(Event.ENTER_FRAME, onLevelPanelEnterFrame);
};
}
private function onLevelPanelClose(_arg1:MouseEvent):void{
closeLevelPanel();
}
private function onWinLevel(_arg1:Event):void{
level.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
level.game.stop();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
trace((("level finished tracking [" + (currLevel + 7)) + "]"));
DoubleQuick.event((currLevel + 7));
currLevel++;
if (currLevel == numLevels){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
level.showWinVideo();
} else {
showLevelPanel(true);
};
}
private function startLevel():void{
if (level){
removeChild(level);
level.dispose();
level.removeEventListener(Level.EVENT_LOSE_LEVEL, onLoseLevel);
level.removeEventListener(Level.EVENT_WIN_LEVEL, onWinLevel);
level.removeEventListener(Level.EVENT_LOSE_VIDEO_FINISHED, onLoseVideoFinished);
level.removeEventListener(Level.EVENT_WIN_VIDEO_FINISHED, onWinVideoFinished);
level = null;
};
levelStarted = false;
trace((("starting level [" + currLevel) + "]"));
switch (currLevel){
case 0:
level = new Level(mc.gameHolder, 3, 0, 0.4, 0.9, mc.video, Constants.VIDEO_URLS[0]);
currLevelThumb = mc.levelThumbs.level0;
break;
case 1:
level = new Level(mc.gameHolder, 3, 2, 0.4, 0.85, mc.video, Constants.VIDEO_URLS[1]);
currLevelThumb = mc.levelThumbs.level1;
break;
case 2:
level = new Level(mc.gameHolder, 2, 1, 0.35, 0.8, mc.video, Constants.VIDEO_URLS[2]);
currLevelThumb = mc.levelThumbs.level2;
break;
case 3:
level = new Level(mc.gameHolder, 3, 3, 0.35, 0.75, mc.video, Constants.VIDEO_URLS[3]);
currLevelThumb = mc.levelThumbs.level3;
break;
};
mc.levelThumbs.level0.gotoAndStop(((currLevel > 0)) ? 3 : 1);
mc.levelThumbs.level1.gotoAndStop(((currLevel > 1)) ? 3 : 1);
mc.levelThumbs.level2.gotoAndStop(((currLevel > 2)) ? 3 : 1);
mc.levelThumbs.level3.gotoAndStop(1);
currLevelThumb.gotoAndStop(2);
level.addEventListener(Level.EVENT_LOSE_LEVEL, onLoseLevel);
level.addEventListener(Level.EVENT_WIN_LEVEL, onWinLevel);
level.addEventListener(Level.EVENT_LOSE_VIDEO_FINISHED, onLoseVideoFinished);
level.addEventListener(Level.EVENT_WIN_VIDEO_FINISHED, onWinVideoFinished);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
if (gameDisabled){
level.disableGame();
};
addChild(level);
mc.distraction_btn.mouseEnabled = true;
}
private function onDistractionPanelLink(_arg1:MouseEvent):void{
DoubleQuick.click(12);
}
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("GameSection") as MovieClip);
mc.distraction_btn.addEventListener(MouseEvent.CLICK, onDistractionClick);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
gameDisabled = false;
}
private function onLevelPanelKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
closeLevelPanel();
};
}
private function gameComplete():void{
Main.smSFX.stopAllSounds();
NextSectionClass = Title;
gotoNextSection();
}
private function onLevelPanelPlayAgainClick(_arg1:MouseEvent):void{
closeLevelPanel();
}
private function onLoseLevel(_arg1:Event):void{
mc.distraction_btn.mouseEnabled = false;
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
level.showLoseVideo();
}
private function onLevelPanelMTVClick(_arg1:MouseEvent):void{
DoubleQuick.click(11);
}
private function onLoseVideoFinished(_arg1:Event):void{
showLevelPanel(false);
}
private function onLevelWinPanelEnterFrame(_arg1:Event):void{
if (((((levelPanel.playAgain_btn) && (levelPanel.mtv_btn))) && (levelPanel.logo_btn))){
levelPanel.playAgain_btn.addEventListener(MouseEvent.CLICK, onLevelPanelPlayAgainClick);
levelPanel.mtv_btn.addEventListener(MouseEvent.CLICK, onLevelPanelMTVClick);
levelPanel.logo_btn.addEventListener(MouseEvent.CLICK, onLevelPanelMTVClick);
level.removeEventListener(Event.ENTER_FRAME, onLevelWinPanelEnterFrame);
};
}
private function onDistractionPanelClose(_arg1:MouseEvent):void{
closeDistractionPanel();
mc.distraction.gotoAndStop((gameDisabled) ? 2 : 1);
}
private function onDistractionClick(_arg1:MouseEvent):void{
distractionPanel = (assetFactory.createDisplayObject("DistractionPanelAsset") as MovieClip);
distractionPanel.x = (0.5 * stage.stageWidth);
distractionPanel.y = (0.5 * stage.stageHeight);
distractionPanel.close_btn.addEventListener(MouseEvent.CLICK, onDistractionPanelClose);
distractionPanel.link_btn.addEventListener(MouseEvent.CLICK, onDistractionPanelLink);
distractionPanel.submit_btn.addEventListener(MouseEvent.CLICK, onDistractionPanelSubmit);
distractionPanel.logo_btn.addEventListener(MouseEvent.CLICK, onLevelPanelMTVClick);
var _local2:TextFormat = new TextFormat();
_local2.color = 0;
distractionPanel.userInput_txt.text = "";
distractionPanel.userInput_txt.setTextFormat(_local2);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onDistractionPanelKeyDown);
stage.focus = distractionPanel.userInput_txt;
if (level){
level.pause();
};
mc.distraction.gotoAndStop(2);
addChild(distractionPanel);
}
override public function dispose():void{
if (distractionPanel){
distractionPanel.close_btn.removeEventListener(MouseEvent.CLICK, onDistractionPanelClose);
distractionPanel.link_btn.removeEventListener(MouseEvent.CLICK, onDistractionPanelLink);
distractionPanel.submit_btn.removeEventListener(MouseEvent.CLICK, onDistractionPanelSubmit);
};
if (level){
removeChild(level);
level.dispose();
level = null;
};
}
private function onPanelTimer(_arg1:Event):void{
panelTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onPanelTimer);
panelTimer = null;
closeLevelPanel();
}
private function onWinVideoFinished(_arg1:Event):void{
showLevelPanel(true);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc.x = (0.5 * stage.stageWidth);
mc.y = (0.5 * stage.stageHeight);
addChild(mc);
initGame();
}
private function onVoiceOverFinished(_arg1:Event):void{
closeLevelPanel();
}
private function submitDistractionCode():void{
var _local2:TextFormat;
var _local1:String = distractionPanel.userInput_txt.text.toLowerCase();
_local1 = _local1.split(" ").join("");
if (_local1 == Constants.DISTRACTION_CODE.toLowerCase()){
gameDisabled = true;
mc.distraction_btn.mouseEnabled = false;
closeDistractionPanel();
} else {
_local2 = new TextFormat();
_local2.color = 0xCC0000;
distractionPanel.userInput_txt.setTextFormat(_local2);
};
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onDistractionPanelKeyDown);
}
private function initGame():void{
currLevel = 0;
numLevels = 4;
startLevel();
}
private function onEnterFrame(_arg1:Event):void{
var _local4:int;
var _local2:Number = level.getCurrentTime();
var _local3:Number = level.getTotalTime();
if (currLevel == 0){
_local2 = (_local2 - 3);
_local3 = (40 - 3);
} else {
if (currLevel == 1){
_local2 = (_local2 - 2);
_local3 = (38 - 2);
} else {
if (currLevel == 2){
_local2 = (_local2 - 2);
_local3 = (75 - 2);
} else {
_local2 = (_local2 - 2);
_local3 = (79 - 2);
};
};
};
if (_local2 < 0){
_local2 = 0;
};
if (currLevelThumb.time){
_local4 = Math.ceil((100 * (_local2 / _local3)));
currLevelThumb.time.gotoAndStop(_local4);
};
if (!levelStarted){
switch (currLevel){
case 0:
if (level.getCurrentTime() > 3){
level.game.start();
levelStarted = true;
};
break;
case 1:
if (level.getCurrentTime() > 2){
level.game.start();
levelStarted = true;
};
break;
case 2:
if (level.getCurrentTime() > 2){
level.game.start();
levelStarted = true;
};
break;
case 3:
if (level.getCurrentTime() > 2){
level.game.start();
levelStarted = true;
};
break;
};
} else {
switch (currLevel){
case 0:
if (level.getCurrentTime() > 40){
onWinLevel(new Event(""));
};
break;
case 1:
if (level.getCurrentTime() > 38){
onWinLevel(new Event(""));
};
break;
case 2:
if (level.getCurrentTime() > 70){
onWinLevel(new Event(""));
};
break;
case 3:
if (level.getCurrentTime() > 79){
onWinLevel(new Event(""));
};
break;
};
};
}
private function closeLevelPanel():void{
if (levelPanel.play_btn){
levelPanel.play_btn.removeEventListener(MouseEvent.CLICK, onLevelPanelClose);
};
if (levelPanel.playAgain_btn){
levelPanel.playAgain_btn.removeEventListener(MouseEvent.CLICK, onLevelPanelPlayAgainClick);
};
if (levelPanel.mtv_btn){
levelPanel.mtv_btn.removeEventListener(MouseEvent.CLICK, onLevelPanelMTVClick);
};
if (levelPanel.logo_btn){
levelPanel.logo_btn.removeEventListener(MouseEvent.CLICK, onLevelPanelMTVClick);
};
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onLevelPanelKeyDown);
removeChild(levelPanel);
if (currLevel == 4){
gameComplete();
} else {
startLevel();
};
Main.smSFX.getSoundFromID("MusicSound").fadeOut(200);
}
private function onDistractionPanelKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.ENTER){
submitDistractionCode();
};
}
private function onDebug(_arg1:MouseEvent):void{
var _local2:TextField = new TextField();
_local2.width = 400;
_local2.height = 300;
_local2.background = true;
_local2.backgroundColor = 0xFFFFFF;
_local2.text = level.debug;
addChild(_local2);
}
private function onDistractionPanelSubmit(_arg1:MouseEvent):void{
submitDistractionCode();
}
private function showLevelPanel(_arg1:Boolean):void{
var _local2:String;
level.pause();
levelPanel = (assetFactory.createDisplayObject((_arg1) ? "LevelWinPanelAsset" : "LevelLosePanelAsset") as MovieClip);
levelPanel.x = (0.5 * stage.stageWidth);
levelPanel.y = (0.5 * stage.stageHeight);
levelPanel.gotoAndStop(currLevel);
if (_arg1){
if (currLevel < 4){
_local2 = (("EndLevel" + currLevel) + "Sound");
Main.smSFX.getSoundFromID(_local2).play();
panelTimer = new Timer(5000, 1);
panelTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onPanelTimer);
panelTimer.start();
level.addEventListener(Event.ENTER_FRAME, onLevelPanelEnterFrame);
} else {
Main.smSFX.getSoundFromID("WinSound").play();
level.addEventListener(Event.ENTER_FRAME, onLevelWinPanelEnterFrame);
};
} else {
levelPanel.play_btn.addEventListener(MouseEvent.CLICK, onLevelPanelClose);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onLevelPanelKeyDown);
level.addEventListener(Event.ENTER_FRAME, onLevelPanelEnterFrame);
};
addChild(levelPanel);
Main.smSFX.getSoundFromID("MusicSound").fadeIn(0, 0.5, 200, 9999999);
}
private function onSkip(_arg1:MouseEvent):void{
onWinLevel(_arg1);
}
}
}//package uk.kerb.calumBest
Section 11
//Instructions (uk.kerb.calumBest.Instructions)
package uk.kerb.calumBest {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.game.*;
import uk.kerb.tracking.*;
import uk.kerb.calumBest.game.*;
import flash.ui.*;
public class Instructions extends AbstractSection {
private var game:LampGame;
public function Instructions(){
DoubleQuick.event(6);
}
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("InstructionsSection") as MovieClip);
mc.stop();
NextSectionClass = Game;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
playOut();
};
}
private function onPlayClick(_arg1:MouseEvent):void{
playOut();
}
override public function dispose():void{
mc.play_btn.removeEventListener(MouseEvent.CLICK, onPlayClick);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
if (game){
game.dispose();
};
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = stage;
mc.play_btn.addEventListener(MouseEvent.CLICK, onPlayClick);
mc.x = (0.5 * stage.stageWidth);
mc.y = (0.5 * stage.stageHeight);
addChild(mc);
Main.smSFX.getSoundFromID("InstructionsSound").play();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function playOut():void{
mc.gotoAndStop("out");
addEventListener(Event.ENTER_FRAME, onEnterFrame);
Main.smSFX.getSoundFromID("InstructionsSound").stop();
Main.smSFX.getSoundFromID("MusicSound").fadeOut(2000);
}
private function onEnterFrame(_arg1:Event):void{
mc.nextFrame();
if (mc.currentFrame == 6){
game = new LampGame(2, 0, 0.4, 0.9);
game.renderer.x = 14;
game.renderer.y = 12;
game.playSFX = false;
game.userControlled = false;
mc.dummyGame.addChild(game);
game.start();
} else {
if (mc.currentFrame == 31){
mc.stop();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
} else {
if (mc.currentFrame == mc.totalFrames){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
gotoNextSection();
};
};
};
}
}
}//package uk.kerb.calumBest
Section 12
//Level (uk.kerb.calumBest.Level)
package uk.kerb.calumBest {
import flash.events.*;
import flash.media.*;
import flash.display.*;
import flash.net.*;
import uk.kerb.utils.game.*;
import uk.kerb.calumBest.game.*;
public class Level extends Sprite {
private var bufferingAnimation:MovieClip;
private var ns:NetStream;
public var debug:String;// = ""
private var duration:Number;
private var showingLoseVideo:Boolean;
private var buffering:Boolean;
private var showingWinVideo:Boolean;
private var nsClient:Object;
public var game:LampGame;
private var videoURL:String;
private var nc:NetConnection;
private var video:Video;
public static const EVENT_WIN_VIDEO_FINISHED:String = "onWinVideoComplete";
public static const EVENT_LOSE_VIDEO_FINISHED:String = "onLoseVideoComplete";
public static const EVENT_WIN_LEVEL:String = "onWinLevel";
public static const EVENT_LOSE_LEVEL:String = "onLoseLevel";
public function Level(_arg1:MovieClip, _arg2:int, _arg3:int, _arg4:Number, _arg5:Number, _arg6:Video, _arg7:String){
this.video = _arg6;
this.videoURL = _arg7;
initVideo();
game = new LampGame(_arg2, _arg3, _arg4, _arg5, 20, 5);
game.addEventListener(EVENT_LOSE_LEVEL, onLoseLevel);
game.renderer.BULB_RADIUS = 10.5;
game.renderer.COL_WIDTH = 22.2;
game.renderer.ROW_HEIGHT = 21;
game.renderer.x = 0;
game.renderer.y = 0;
game.renderer.energyMeter.scaleX = 0.754;
game.renderer.energyMeter.scaleY = 0.754;
game.renderer.energyMeter.x = 456;
game.renderer.energyMeter.y = 2;
_arg1.addChild(game);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
bufferingAnimation = (Main.assetFactory.createDisplayObject("BufferingAsset") as MovieClip);
bufferingAnimation.x = 180;
bufferingAnimation.y = 230;
buffering = false;
duration = 10000000;
showingLoseVideo = false;
showingWinVideo = false;
}
private function onEnterFrame(_arg1:Event):void{
if (ns){
if (showingLoseVideo){
if (getCurrentTime() > 9){
dispatchEvent(new Event(EVENT_LOSE_VIDEO_FINISHED));
};
} else {
if (showingWinVideo){
if (getCurrentTime() > 9){
dispatchEvent(new Event(EVENT_WIN_VIDEO_FINISHED));
};
};
};
bufferingAnimation.y = (video.y + 416);
if (ns.bufferLength == 0){
pause();
addChild(bufferingAnimation);
buffering = true;
} else {
if (buffering){
buffering = false;
removeChild(bufferingAnimation);
};
};
};
}
public function unpause():void{
game.start();
if (ns){
ns.resume();
};
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onNetConnectionStatus(_arg1:NetStatusEvent):void{
trace((("onNetConnectionStatus[" + _arg1.info.code) + "]"));
debug = (debug + (("onNetConnectionStatus[" + _arg1.info.code) + "]\n"));
if (_arg1.info.code == "NetConnection.Connect.Success"){
showVideo();
} else {
trace("ERROR?!?");
nc.connect(null);
};
}
private function onLoseLevel(_arg1:Event):void{
pause();
dispatchEvent(new Event(EVENT_LOSE_LEVEL));
}
private function onNetStreamError(_arg1:Event):void{
trace(("NET STREAM ERROR:\n" + _arg1));
}
private function initVideo():void{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetConnectionStatus);
nc.connect(null);
}
private function onMetaData(_arg1:Object):void{
duration = _arg1.duration;
}
private function onNetStatus(_arg1:NetStatusEvent):void{
trace((("onNetStatus[" + _arg1.info.code) + "]"));
debug = (debug + (("onNetStatus[" + _arg1.info.code) + "]\n"));
if (_arg1.info.code == "NetStream.Play.Stop"){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
dispatchEvent(new Event(EVENT_WIN_LEVEL));
} else {
if (_arg1.info.code == "NetStream.Play.StreamNotFound"){
trace("ERROR: VIDEO NOT FOUND");
} else {
if (_arg1.info.code == "NetStream.Play.Start"){
ns.resume();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
} else {
if (_arg1.info.code == "NetStream.Buffer.Flush"){
if (showingLoseVideo){
} else {
if (showingWinVideo){
};
};
};
};
};
};
}
public function showWinVideo():void{
if (ns){
ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStreamError);
ns.removeEventListener(IOErrorEvent.IO_ERROR, onNetStreamError);
ns.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns = null;
};
ns = new NetStream(nc);
ns.bufferTime = 5;
nsClient = new Object();
nsClient.onMetaData = onMetaData;
ns.client = nsClient;
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStreamError);
ns.addEventListener(IOErrorEvent.IO_ERROR, onNetStreamError);
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns.play(Constants.WIN_VIDEO_URL);
video.attachNetStream(ns);
showingWinVideo = true;
}
public function getTotalTime():Number{
return (duration);
}
public function dispose():void{
game.removeEventListener(EVENT_LOSE_LEVEL, onLoseLevel);
game.dispose();
if (nc){
nc.removeEventListener(NetStatusEvent.NET_STATUS, onNetConnectionStatus);
};
if (ns){
ns.pause();
ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStreamError);
ns.removeEventListener(IOErrorEvent.IO_ERROR, onNetStreamError);
ns.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
};
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function showLoseVideo():void{
if (ns){
ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStreamError);
ns.removeEventListener(IOErrorEvent.IO_ERROR, onNetStreamError);
ns.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns = null;
};
ns = new NetStream(nc);
ns.bufferTime = 5;
nsClient = new Object();
nsClient.onMetaData = onMetaData;
ns.client = nsClient;
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStreamError);
ns.addEventListener(IOErrorEvent.IO_ERROR, onNetStreamError);
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns.play(Constants.LOSE_VIDEO_URL);
video.attachNetStream(ns);
showingLoseVideo = true;
}
public function getCurrentTime():Number{
if (ns){
return (ns.time);
};
return (0);
}
public function disableGame():void{
game.disable();
}
public function pause():void{
game.stop();
if (ns){
ns.pause();
};
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function showVideo():void{
if (ns){
ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStreamError);
ns.removeEventListener(IOErrorEvent.IO_ERROR, onNetStreamError);
ns.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns = null;
};
ns = new NetStream(nc);
ns.bufferTime = 10;
nsClient = new Object();
nsClient.onMetaData = onMetaData;
ns.client = nsClient;
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStreamError);
ns.addEventListener(IOErrorEvent.IO_ERROR, onNetStreamError);
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns.play(videoURL);
video.attachNetStream(ns);
}
}
}//package uk.kerb.calumBest
Section 13
//Main (uk.kerb.calumBest.Main)
package uk.kerb.calumBest {
import uk.kerb.utils.game.*;
import uk.kerb.tracking.*;
public class Main extends Main {
public function Main(_arg1:Class){
super(_arg1);
}
override protected function start():void{
DoubleQuick.init(root, 2);
gotoSection(Voiceover);
}
override protected function initSounds():void{
super.initSounds();
initSound("EndLevel1Sound", smSFX);
initSound("EndLevel2Sound", smSFX);
initSound("EndLevel3Sound", smSFX);
initSound("InstructionsSound", smSFX);
initSound("TitleSound", smSFX);
initSound("VoiceoverSound", smSFX);
initSound("WinSound", smSFX);
initSound("HitSound", smSFX);
initSound("MusicSound", smSFX);
}
}
}//package uk.kerb.calumBest
Section 14
//Preload (uk.kerb.calumBest.Preload)
package uk.kerb.calumBest {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.*;
import flash.utils.*;
public class Preload extends MovieClip {
private var SWFBytes:Class;
private var af:AssetFactory;
private var preloadDisplay:MovieClip;
public function Preload(){
SWFBytes = Preload_SWFBytes;
super();
stop();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
af = new AssetFactory();
af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
af.initialize(SWFBytes);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:Number = root.loaderInfo.bytesLoaded;
var _local3:Number = root.loaderInfo.bytesTotal;
var _local4:Number = (_local2 / _local3);
if (preloadDisplay.bar_mc){
if (preloadDisplay.bar_mc.lights_mc){
preloadDisplay.bar_mc.lights_mc.gotoAndStop(Math.ceil((100 * _local4)));
};
};
if (_local4 == 1){
preloadDisplay.nextFrame();
if (preloadDisplay.currentFrame == preloadDisplay.totalFrames){
preloadComplete();
};
};
}
private function onAssetFactoryReady(_arg1:Event):void{
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
preloadDisplay = (af.createDisplayObject("PreloaderAsset") as MovieClip);
addChild(preloadDisplay);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function preloadComplete():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
nextFrame();
removeChild(preloadDisplay);
var _local1:Class = Class(getDefinitionByName("CalumBest"));
if (_local1){
addChild((new (_local1) as Sprite));
};
}
}
}//package uk.kerb.calumBest
Section 15
//Preload_SWFBytes (uk.kerb.calumBest.Preload_SWFBytes)
package uk.kerb.calumBest {
import mx.core.*;
public class Preload_SWFBytes extends ByteArrayAsset {
}
}//package uk.kerb.calumBest
Section 16
//Title (uk.kerb.calumBest.Title)
package uk.kerb.calumBest {
import flash.events.*;
import flash.media.*;
import flash.display.*;
import uk.kerb.utils.game.*;
import flash.ui.*;
public class Title extends AbstractSection {
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("TitleSection") as MovieClip);
NextSectionClass = Instructions;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc.instructions_btn.addEventListener(MouseEvent.CLICK, onInstructionsClick);
mc.skipIntro_btn.addEventListener(MouseEvent.CLICK, onSkipIntroClick);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc.sign.lights.gotoAndPlay(50);
mc.x = (0.5 * stage.stageWidth);
mc.y = (0.5 * stage.stageHeight);
addChild(mc);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = stage;
Main.smSFX.getSoundFromID("TitleSound").play();
var _local2:SoundChannel = Main.smSFX.getSoundFromID("TitleSound").getSoundChannel();
_local2.addEventListener(Event.SOUND_COMPLETE, onVoiceOverFinished);
}
private function onInstructionsClick(_arg1:MouseEvent):void{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
override public function dispose():void{
mc.instructions_btn.removeEventListener(MouseEvent.CLICK, onInstructionsClick);
mc.skipIntro_btn.removeEventListener(MouseEvent.CLICK, onSkipIntroClick);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
var _local1:SoundChannel = Main.smSFX.getSoundFromID("TitleSound").getSoundChannel();
_local1.addEventListener(Event.SOUND_COMPLETE, onVoiceOverFinished);
}
private function onVoiceOverFinished(_arg1:Event):void{
mc.play();
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
gotoNextSection();
};
}
private function onSkipIntroClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("TitleSound").stop();
gotoNextSection();
}
private function onEnterFrame(_arg1:Event):void{
mc.nextFrame();
if (mc.currentFrame == mc.totalFrames){
gotoNextSection();
Main.smSFX.getSoundFromID("TitleSound").stop();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
};
}
}
}//package uk.kerb.calumBest
Section 17
//Voiceover (uk.kerb.calumBest.Voiceover)
package uk.kerb.calumBest {
import flash.events.*;
import flash.media.*;
import flash.display.*;
import uk.kerb.utils.game.*;
public class Voiceover extends AbstractSection {
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("VoiceoverSection") as MovieClip);
NextSectionClass = Title;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc.x = (0.5 * stage.stageWidth);
mc.y = (0.5 * stage.stageHeight);
addChild(mc);
Main.smSFX.getSoundFromID("VoiceoverSound").play();
Main.smSFX.getSoundFromID("MusicSound").fadeIn(0.7, 0.8, 100, 9999999);
var _local2:SoundChannel = Main.smSFX.getSoundFromID("VoiceoverSound").getSoundChannel();
_local2.addEventListener(Event.SOUND_COMPLETE, onVoiceOverFinished);
mc.skipIntro_btn.addEventListener(MouseEvent.CLICK, onSkipIntro);
}
override public function dispose():void{
var _local1:SoundChannel = Main.smSFX.getSoundFromID("VoiceoverSound").getSoundChannel();
if (_local1){
_local1.removeEventListener(Event.SOUND_COMPLETE, onVoiceOverFinished);
};
}
private function onVoiceOverFinished(_arg1:Event):void{
gotoNextSection();
}
private function onSkipIntro(_arg1:MouseEvent):void{
NextSectionClass = Instructions;
Main.smSFX.getSoundFromID("VoiceoverSound").stop();
gotoNextSection();
}
}
}//package uk.kerb.calumBest
Section 18
//DoubleQuick (uk.kerb.tracking.DoubleQuick)
package uk.kerb.tracking {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class DoubleQuick {
private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey";
private static const SO_EXPIRY_PROPERTY_NAME:String = "expo";
private static const SO_NAME:String = "doublequick";
private static const TRACKER_URL:String = "http://doublequick.kerb.co.uk/tracking/trackflash.htm";
private static const TRACKER_SESSION_URL:String = "http://doublequick.kerb.co.uk/tracking/session.htm";
private static var initialised:Boolean = false;
private static var queue:Array = new Array();
private static var projectId:Number;
private static var baseurl:String;
public static function click(_arg1:Number):void{
trace(("Tracking clickThrough " + _arg1));
navigateToURL(generateURL(_arg1));
}
public static function event(_arg1:Number):void{
var loader:URLLoader;
var request:URLRequest;
var watchId = _arg1;
if (!initialised){
trace(("Queueing event " + watchId));
queue.push(watchId);
} else {
trace(("Tracking event " + watchId));
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request = generateURL(watchId);
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
};
}
private static function generateURL(_arg1:Number):URLRequest{
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl));
return (new URLRequest(_local3));
}
private static function onInit(_arg1:Event):void{
var _local5:Date;
var _local2:URLLoader = URLLoader(_arg1.target);
var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){
trace(("acquired session key " + _local2.data["sessionkey"]));
_local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]);
_local5 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000)));
_local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local5);
};
initialised = true;
var _local4:int;
while (_local4 < queue.length) {
event(queue[_local4]);
_local4++;
};
queue = new Array();
}
public static function init(_arg1:DisplayObject, _arg2:Number):void{
var loader:URLLoader;
var request:URLRequest;
var root = _arg1;
var _projectId = _arg2;
projectId = _projectId;
baseurl = root.loaderInfo.url;
trace(((("Tracking initialised with project " + projectId) + " and baseurl ") + baseurl));
var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var isExpired:Boolean;
var currentDate:Date = new Date();
if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){
isExpired = false;
};
if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){
trace("requesting new session key");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onInit);
request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId));
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
};
}
}
}//package uk.kerb.tracking
Section 19
//AbstractSection (uk.kerb.utils.game.AbstractSection)
package uk.kerb.utils.game {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.ui.*;
public class AbstractSection extends MovieClip implements IDisposable {
protected var NextSectionClass:Class;
protected var PreviousSectionClass:Class;
protected var mc:MovieClip;
protected var assetFactory:AssetFactory;
public function AbstractSection(){
assetFactory = Main.assetFactory;
}
public function dispose():void{
}
protected function gotoNextSection():void{
dispatchEvent(new Event(Event.COMPLETE));
}
public function init(_arg1:Class):void{
this.PreviousSectionClass = _arg1;
}
public function getNextSection():Class{
return (NextSectionClass);
}
}
}//package uk.kerb.utils.game
Section 20
//AssetFactory (uk.kerb.utils.game.AssetFactory)
package uk.kerb.utils.game {
import flash.events.*;
import uk.co.stdio.sound.*;
import flash.display.*;
public final class AssetFactory extends EventDispatcher {
private var _loader:Loader;// = null
public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY";
public function initialize(_arg1:Class):void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
_loader.loadBytes(new (_arg1));
}
public function createDisplayObject(_arg1:String):DisplayObject{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as DisplayObject));
}
private function _onLibraryReady(_arg1:Event):void{
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady);
dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY));
}
public function createSound(_arg1:String):ExtendedSound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as ExtendedSound));
}
public function createBitmapDataObject(_arg1:String):BitmapData{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new _local2(0, 0) as BitmapData));
}
private function _onIOError(_arg1:Event):void{
}
}
}//package uk.kerb.utils.game
Section 21
//KeyControl (uk.kerb.utils.game.KeyControl)
package uk.kerb.utils.game {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.ui.*;
public class KeyControl implements IDisposable {
protected var activeKeys:Array;
protected var stage:Stage;
private static var allowInstantiation:Boolean = false;
private static var instance:KeyControl;
public function KeyControl(){
activeKeys = new Array();
super();
if (!allowInstantiation){
throw (new Error("KeyControl is a singleton. Use getInstance() to instantiate."));
};
}
public function init(_arg1:Stage):void{
this.stage = _arg1;
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
_arg1.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
protected function onKeyDown(_arg1:KeyboardEvent):void{
activeKeys[_arg1.keyCode] = true;
}
public function keyIsDown(_arg1:uint):Boolean{
return (activeKeys[_arg1]);
}
protected function onKeyUp(_arg1:KeyboardEvent):void{
activeKeys[_arg1.keyCode] = false;
}
public function dispose():void{
if (stage){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
};
}
public static function getInstance():KeyControl{
if (instance == null){
allowInstantiation = true;
instance = new (KeyControl);
allowInstantiation = false;
};
return (instance);
}
}
}//package uk.kerb.utils.game
Section 22
//Main (uk.kerb.utils.game.Main)
package uk.kerb.utils.game {
import flash.events.*;
import uk.co.stdio.sound.*;
import flash.display.*;
public class Main extends Sprite {
protected var PreviousSectionClass:Class;
protected var currentSection:AbstractSection;
public static var smSFX:SoundManager;
public static var assetFactory:AssetFactory;
public static var smMusic:SoundManager;
public function Main(_arg1:Class){
assetFactory = new AssetFactory();
assetFactory.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
assetFactory.initialize(_arg1);
}
protected function init():void{
initSounds();
start();
}
protected function gotoSection(_arg1:Class):void{
if (currentSection != null){
currentSection.removeEventListener(Event.COMPLETE, onSectionComplete);
currentSection.dispose();
removeChild(currentSection);
};
currentSection = new (_arg1);
currentSection.init(PreviousSectionClass);
currentSection.addEventListener(Event.COMPLETE, onSectionComplete);
addChild(currentSection);
PreviousSectionClass = _arg1;
}
protected function initSound(_arg1:String, _arg2:SoundManager):void{
var _local3:ExtendedSound = (assetFactory.createSound(_arg1) as ExtendedSound);
_arg2.registerSound(_local3, _arg1);
}
protected function start():void{
}
protected function onAssetFactoryReady(_arg1:Event):void{
assetFactory.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
init();
}
protected function initSounds():void{
Main.smMusic = new SoundManager("music");
Main.smSFX = new SoundManager("sfx");
}
protected function onSectionComplete(_arg1:Event):void{
gotoSection(currentSection.getNextSection());
}
}
}//package uk.kerb.utils.game
Section 23
//ExtendedSound (uk.kerb.utils.sound.ExtendedSound)
package uk.kerb.utils.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ExtendedSound extends Sound {
private var fadeStartVolume:Number;
private var fadeEndVolume:Number;
private var panStartPosition:Number;
private var panDuration:Number;
private var panEndPosition:Number;
private var fadeTimer:Timer;
private var panTimer:Timer;
private var fadeDuration:Number;
private var panStartTime:Number;
private var fadeStartTime:Number;
private var soundChannel:SoundChannel;
private static const TIMER_UPDATE_RATE:Number = 20;
public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{
fadeStartVolume = Math.max(0, Math.min(1, _arg1));
soundChannel = super.play(_arg5, _arg4, new SoundTransform(fadeStartVolume));
if (_arg3 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg3;
fadeEndVolume = Math.max(0, Math.min(1, _arg2));
startFade();
};
return (soundChannel);
}
public function stop():void{
if (soundChannel != null){
soundChannel.stop();
};
}
public function fadeOut(_arg1:Number=0):void{
if (_arg1 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg1;
fadeStartVolume = soundChannel.soundTransform.volume;
fadeEndVolume = 0;
startFade();
} else {
stop();
};
}
protected function stopPan():void{
if (((!((panTimer == null))) && (panTimer.running))){
panTimer.reset();
};
}
protected function updatePan(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - panStartTime) / panDuration);
if (_local3 >= 1){
stopPan();
_local2 = panEndPosition;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition);
};
};
var _local4:Number = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local4, _local2);
}
public function setPan(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(-1, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local2, _arg1);
stopPan();
};
}
protected function stopFade():void{
if (((!((fadeTimer == null))) && (fadeTimer.running))){
fadeTimer.reset();
};
}
public function setVolume(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(0, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform(_arg1, _local2);
stopFade();
};
}
protected function updateFade(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration);
if (_local3 >= 1){
stopFade();
_local2 = fadeEndVolume;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume);
};
};
var _local4:Number = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform(_local2, _local4);
}
protected function startPan():void{
if (panTimer == null){
panTimer = new Timer(TIMER_UPDATE_RATE);
panTimer.addEventListener(TimerEvent.TIMER, updatePan);
};
stopPan();
panTimer.start();
}
public function panTo(_arg1:Number, _arg2:Number):void{
if (_arg2 > 0){
panStartTime = getTimer();
panDuration = _arg2;
panStartPosition = soundChannel.soundTransform.pan;
panEndPosition = _arg1;
startPan();
} else {
setPan(_arg1);
};
}
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
soundChannel = super.play(_arg1, _arg2, _arg3);
return (soundChannel);
}
protected function startFade():void{
if (fadeTimer == null){
fadeTimer = new Timer(TIMER_UPDATE_RATE);
fadeTimer.addEventListener(TimerEvent.TIMER, updateFade);
};
stopFade();
fadeTimer.start();
}
}
}//package uk.kerb.utils.sound
Section 24
//IDisposable (uk.kerb.utils.ui.IDisposable)
package uk.kerb.utils.ui {
public interface IDisposable {
function dispose():void;
}
}//package uk.kerb.utils.ui
Section 25
//AssetFactory (uk.kerb.utils.AssetFactory)
package uk.kerb.utils {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.sound.*;
public final class AssetFactory extends EventDispatcher {
private var _loader:Loader;// = null
public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY";
public function initialize(_arg1:Class):void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
_loader.loadBytes(new (_arg1));
}
public function createDisplayObject(_arg1:String):DisplayObject{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as DisplayObject));
}
private function _onLibraryReady(_arg1:Event):void{
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady);
dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY));
}
public function createSound(_arg1:String):ExtendedSound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as ExtendedSound));
}
public function createBitmapDataObject(_arg1:String):BitmapData{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new _local2(0, 0) as BitmapData));
}
private function _onIOError(_arg1:Event):void{
}
}
}//package uk.kerb.utils
Section 26
//CalumBest (CalumBest)
package {
import flash.display.*;
import uk.kerb.calumBest.*;
public class CalumBest extends Sprite {
private var SWFBytes:Class;
public function CalumBest(){
SWFBytes = CalumBest_SWFBytes;
super();
addChild(new Main(SWFBytes));
}
}
}//package
Section 27
//CalumBest_SWFBytes (CalumBest_SWFBytes)
package {
import mx.core.*;
public class CalumBest_SWFBytes extends ByteArrayAsset {
}
}//package