Section 1
//Regular (fl.transitions.easing.Regular)
package fl.transitions.easing {
public class Regular {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _arg1) * _arg1) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * _arg1) * _arg1) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
}
}//package fl.transitions.easing
Section 2
//Tween (fl.transitions.Tween)
package fl.transitions {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class Tween extends EventDispatcher {
private var _position:Number;// = NAN
public var prevTime:Number;// = NAN
public var prevPos:Number;// = NAN
public var isPlaying:Boolean;// = false
public var begin:Number;// = NAN
private var _fps:Number;// = NAN
private var _time:Number;// = NAN
public var change:Number;// = NAN
private var _finish:Number;// = NAN
public var looping:Boolean;// = false
private var _intervalID:uint;// = 0
public var func:Function;
private var _timer:Timer;// = null
private var _startTime:Number;// = NAN
public var prop:String;// = ""
private var _duration:Number;// = NAN
public var obj:Object;// = null
public var useSeconds:Boolean;// = false
protected static var _mc:MovieClip = new MovieClip();
public function Tween(_arg1:Object, _arg2:String, _arg3:Function, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false){
isPlaying = false;
obj = null;
prop = "";
func = function (_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
};
begin = NaN;
change = NaN;
useSeconds = false;
prevTime = NaN;
prevPos = NaN;
looping = false;
_duration = NaN;
_time = NaN;
_fps = NaN;
_position = NaN;
_startTime = NaN;
_intervalID = 0;
_finish = NaN;
_timer = null;
super();
if (!arguments.length){
return;
};
this.obj = _arg1;
this.prop = _arg2;
this.begin = _arg4;
this.position = _arg4;
this.duration = _arg6;
this.useSeconds = _arg7;
if ((_arg3 is Function)){
this.func = _arg3;
};
this.finish = _arg5;
this._timer = new Timer(100);
this.start();
}
public function continueTo(_arg1:Number, _arg2:Number):void{
this.begin = this.position;
this.finish = _arg1;
if (!isNaN(_arg2)){
this.duration = _arg2;
};
this.start();
}
public function stop():void{
this.stopEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_STOP, this._time, this._position));
}
private function fixTime():void{
if (this.useSeconds){
this._startTime = (getTimer() - (this._time * 1000));
};
}
public function set FPS(_arg1:Number):void{
var _local2:Boolean;
_local2 = this.isPlaying;
this.stopEnterFrame();
this._fps = _arg1;
if (_local2){
this.startEnterFrame();
};
}
public function get finish():Number{
return ((this.begin + this.change));
}
public function get duration():Number{
return (this._duration);
}
protected function startEnterFrame():void{
var _local1:Number;
if (isNaN(this._fps)){
_mc.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, false, 0, true);
} else {
_local1 = (1000 / this._fps);
this._timer.delay = _local1;
this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler, false, 0, true);
this._timer.start();
};
this.isPlaying = true;
}
public function set time(_arg1:Number):void{
this.prevTime = this._time;
if (_arg1 > this.duration){
if (this.looping){
this.rewind((_arg1 - this._duration));
this.update();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_LOOP, this._time, this._position));
} else {
if (this.useSeconds){
this._time = this._duration;
this.update();
};
this.stop();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH, this._time, this._position));
};
} else {
if (_arg1 < 0){
this.rewind();
this.update();
} else {
this._time = _arg1;
this.update();
};
};
}
protected function stopEnterFrame():void{
if (isNaN(this._fps)){
_mc.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
} else {
this._timer.stop();
};
this.isPlaying = false;
}
public function getPosition(_arg1:Number=NaN):Number{
if (isNaN(_arg1)){
_arg1 = this._time;
};
return (this.func(_arg1, this.begin, this.change, this._duration));
}
public function set finish(_arg1:Number):void{
this.change = (_arg1 - this.begin);
}
public function set duration(_arg1:Number):void{
this._duration = ((_arg1)<=0) ? Infinity : _arg1;
}
public function setPosition(_arg1:Number):void{
this.prevPos = this._position;
if (this.prop.length){
this.obj[this.prop] = (this._position = _arg1);
};
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_CHANGE, this._time, this._position));
}
public function resume():void{
this.fixTime();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_RESUME, this._time, this._position));
}
public function fforward():void{
this.time = this._duration;
this.fixTime();
}
protected function onEnterFrame(_arg1:Event):void{
this.nextFrame();
}
public function get position():Number{
return (this.getPosition(this._time));
}
public function yoyo():void{
this.continueTo(this.begin, this.time);
}
public function nextFrame():void{
if (this.useSeconds){
this.time = ((getTimer() - this._startTime) / 1000);
} else {
this.time = (this._time + 1);
};
}
protected function timerHandler(_arg1:TimerEvent):void{
this.nextFrame();
_arg1.updateAfterEvent();
}
public function get FPS():Number{
return (this._fps);
}
public function rewind(_arg1:Number=0):void{
this._time = _arg1;
this.fixTime();
this.update();
}
public function set position(_arg1:Number):void{
this.setPosition(_arg1);
}
public function get time():Number{
return (this._time);
}
private function update():void{
this.setPosition(this.getPosition(this._time));
}
public function start():void{
this.rewind();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_START, this._time, this._position));
}
public function prevFrame():void{
if (!this.useSeconds){
this.time = (this._time - 1);
};
}
}
}//package fl.transitions
Section 3
//TweenEvent (fl.transitions.TweenEvent)
package fl.transitions {
import flash.events.*;
public class TweenEvent extends Event {
public var time:Number;// = NAN
public var position:Number;// = NAN
public static const MOTION_START:String = "motionStart";
public static const MOTION_STOP:String = "motionStop";
public static const MOTION_LOOP:String = "motionLoop";
public static const MOTION_CHANGE:String = "motionChange";
public static const MOTION_FINISH:String = "motionFinish";
public static const MOTION_RESUME:String = "motionResume";
public function TweenEvent(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Boolean=false){
time = NaN;
position = NaN;
super(_arg1, _arg4, _arg5);
this.time = _arg2;
this.position = _arg3;
}
override public function clone():Event{
return (new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable));
}
}
}//package fl.transitions
Section 4
//menubutton_3 (Spinball_fla.menubutton_3)
package Spinball_fla {
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
import flash.ui.*;
public dynamic class menubutton_3 extends MovieClip {
public function menubutton_3(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Spinball_fla
Section 5
//soundToggle_2 (Spinball_fla.soundToggle_2)
package Spinball_fla {
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
import flash.ui.*;
public dynamic class soundToggle_2 extends MovieClip {
public function soundToggle_2(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Spinball_fla
Section 6
//Ball (Ball)
package {
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.text.*;
import flash.media.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.filters.*;
import flash.system.*;
import flash.ui.*;
public dynamic class Ball extends MovieClip {
public function Ball(){
addFrameScript(0, frame1, 29, frame30);
}
function frame1(){
stop();
}
function frame30(){
if (this.onLastFrame){
this.onLastFrame();
};
}
}
}//package
Section 7
//ButtonGreen (ButtonGreen)
package {
public dynamic class ButtonGreen extends Peg {
}
}//package
Section 8
//ButtonRed (ButtonRed)
package {
public dynamic class ButtonRed extends Peg {
}
}//package
Section 9
//CanCola (CanCola)
package {
public dynamic class CanCola extends Peg {
}
}//package
Section 10
//CanGinger (CanGinger)
package {
public dynamic class CanGinger extends Peg {
}
}//package
Section 11
//CanTuna (CanTuna)
package {
public dynamic class CanTuna extends Peg {
}
}//package
Section 12
//CapCola (CapCola)
package {
public dynamic class CapCola extends Peg {
}
}//package
Section 13
//CapCream (CapCream)
package {
public dynamic class CapCream extends Peg {
}
}//package
Section 14
//CapGinger (CapGinger)
package {
public dynamic class CapGinger extends Peg {
}
}//package
Section 15
//CapRoot (CapRoot)
package {
public dynamic class CapRoot extends Peg {
}
}//package
Section 16
//CollisionMap (CollisionMap)
package {
import flash.display.*;
import flash.geom.*;
public class CollisionMap {
private var tiles:Object;
private var tilesize:uint;
private var tilesByClipName:Object;
public function CollisionMap(_arg1:uint){
this.tilesize = _arg1;
tiles = new Object();
tilesByClipName = new Object();
}
public function register(_arg1:MovieClip):void{
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
deregister(_arg1);
tilesByClipName[_arg1.name] = new Array();
_local2 = tileIndex((_arg1.x - _arg1.radius));
_local3 = tileIndex((_arg1.x + _arg1.radius));
_local4 = tileIndex((_arg1.y - _arg1.radius));
_local5 = tileIndex((_arg1.y + _arg1.radius));
_local6 = _local2;
while (_local6 <= _local3) {
_local7 = _local4;
while (_local7 <= _local5) {
_local8 = addTile(_local6, _local7);
_local8.addClip(_arg1);
tilesByClipName[_arg1.name].push(_local8);
_local7++;
};
_local6++;
};
}
public function deregister(_arg1:MovieClip):void{
var _local2:*;
var _local3:*;
_local2 = tilesByClipName[_arg1.name];
if (!_local2){
return;
};
while (_local2.length) {
_local3 = _local2.pop();
_local3.removeClip(_arg1);
};
tilesByClipName[_arg1.name] = null;
}
private function getTile(_arg1, _arg2):CollisionMapTile{
return (tiles[((_arg1 + "_") + _arg2)]);
}
private function addTile(_arg1, _arg2):CollisionMapTile{
var _local3:*;
_local3 = getTile(_arg1, _arg2);
if (_local3){
return (_local3);
};
_local3 = new CollisionMapTile();
tiles[((_arg1 + "_") + _arg2)] = _local3;
return (_local3);
}
public function getClipsNearPoint(_arg1:Point, _arg2:Number):Array{
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
var _local12:*;
_local3 = tileIndex((_arg1.x - _arg2));
_local4 = tileIndex((_arg1.x + _arg2));
_local5 = tileIndex((_arg1.y - _arg2));
_local6 = tileIndex((_arg1.y + _arg2));
_local7 = new Array();
_local9 = _local3;
while (_local9 <= _local4) {
_local10 = _local5;
while (_local10 <= _local6) {
_local11 = getTile(_local9, _local10);
if (!_local11){
} else {
_local8 = _local11.getClips();
for (_local12 in _local8) {
_local7.push(_local8[_local12]);
};
};
_local10++;
};
_local9++;
};
return (_local7);
}
private function tileIndex(_arg1:Number):int{
return (Math.floor((_arg1 / tilesize)));
}
}
}//package
Section 17
//CollisionMapTile (CollisionMapTile)
package {
import flash.display.*;
public class CollisionMapTile {
private var clips:Array;
public function CollisionMapTile(){
clips = new Array();
}
public function removeClip(_arg1:MovieClip):Boolean{
var _local2:*;
for (_local2 in clips) {
if (_arg1 != clips[_local2]){
} else {
clips.splice(_local2, 1);
return (true);
};
};
return (false);
}
public function addClip(_arg1:MovieClip):void{
clips.push(_arg1);
}
public function getClips():Array{
return (clips.concat());
}
}
}//package
Section 18
//Game (Game)
package {
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import fl.transitions.easing.*;
import fl.transitions.*;
import flash.utils.*;
import flash.net.*;
import flash.ui.*;
public class Game extends MovieClip {
protected var isDown:Array;
public var space:MovieClip;
protected var goal:MovieClip;
protected var levelStartTime:uint;
protected var pauseScreen:MovieClip;
protected var startMarker:MovieClip;
protected var levelPauseLength:uint;// = 0
protected var map:CollisionMap;
protected var goalScreen:MovieClip;
protected var startScreen:MovieClip;
protected var records:SharedObject;
public var currentLevel:uint;// = 1
public var resumeAudio:Boolean;// = true
protected var levelFinishTime:uint;
protected var levelPauseTime:uint;
public var gamePaused:Boolean;// = false
protected var exploreMode:String;
protected var ball:MovieClip;
public static const TOTAL_LEVELS:uint = 11;
public static const sharedObjectID:String = "spinball";
public function Game():void{
currentLevel = 1;
levelPauseLength = 0;
gamePaused = false;
resumeAudio = true;
super();
init();
}
protected function onKey(_arg1:KeyboardEvent):void{
var _local2:*;
if ((((_arg1.keyCode == 80)) && ((_arg1.type == "keyUp")))){
if (gamePaused == false){
showPauseScreen();
levelPauseTime = getTimer();
gamePaused = true;
if (parent.soundToggle.currentLabel == "ON"){
parent.stopMusic();
parent.soundToggle.gotoAndStop("OFF");
} else {
resumeAudio = false;
};
} else {
hidePauseScreen();
_local2 = (getTimer() - levelPauseTime);
levelPauseLength = (levelPauseLength + _local2);
gamePaused = false;
if (resumeAudio){
if (parent.soundToggle.currentLabel == "OFF"){
parent.soundToggle.gotoAndStop("ON");
parent.startMusic();
};
};
};
} else {
switch (_arg1.type){
case "keyDown":
isDown[_arg1.keyCode] = 1;
break;
default:
isDown[_arg1.keyCode] = 0;
break;
};
};
}
public function setupLevel():void{
var _local1:int;
var _local2:*;
if (currentLevel == 1){
records.data.times = new Array();
};
map = new CollisionMap(50);
if (space.level){
space.removeChild(space.level);
};
space.level = new (getDefinitionByName(("Level" + currentLevel)));
space.addChild(space.level);
_local1 = 0;
while (_local1 < space.level.numChildren) {
_local2 = space.level.getChildAt(_local1);
if ((((_local2 is Peg)) || ((_local2 is Hole)))){
setRadius(_local2);
map.register(_local2);
if ((_local2 is Goal)){
goal = _local2;
};
} else {
if ((_local2 is StartMarker)){
startMarker = _local2;
};
};
_local1++;
};
exploreMode = "explore";
showStartScreen();
initBall();
levelPauseLength = 0;
levelStartTime = getTimer();
}
protected function init():void{
space.radius = 605;
space.w = 0;
records = SharedObject.getLocal(sharedObjectID);
if (!records.data.times){
records.data.times = new Array();
};
if (!records.data.bestTimes){
records.data.bestTimes = new Array();
};
}
protected function rad(_arg1:Number):Number{
return (((_arg1 * Math.PI) / 180));
}
protected function showMenu(_arg1:MouseEvent=null):void{
hideGoalScreen();
parent.showTitleScreen();
}
protected function zoomSpace():void{
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
_local1 = (keyIsDown(Keyboard.UP) - keyIsDown(Keyboard.DOWN));
if (!_local1){
return;
};
_local2 = 0.05;
_local3 = (space.scaleX + (_local1 * _local2));
_local4 = 0.9;
_local5 = 0.5;
_local3 = Math.min(Math.max(_local5, _local3), _local4);
space.scaleX = (space.scaleY = _local3);
}
protected function showStartScreen():void{
if (!startScreen){
startScreen = new StartScreen();
};
startScreen.level_tf.text = currentLevel;
startScreen.level_tf.autoSize = "center";
addChild(startScreen);
}
protected function keyIsDown(_arg1:int):int{
return (int(isDown[_arg1]));
}
protected function initBall():void{
if (ball){
space.removeChild(ball);
};
ball = new Ball();
space.addChild(ball);
ball.radius = 16;
ball.x = startMarker.x;
ball.y = startMarker.y;
ball.vx = 0;
ball.vy = 0;
ball.onLastFrame = function (){
if (this.completed){
showGoalScreen();
this.stop();
} else {
resetBall();
};
};
resetBall();
}
protected function deg(_arg1:Number):Number{
return (((_arg1 * 180) / Math.PI));
}
protected function showGoalScreen():void{
if (!goalScreen){
goalScreen = new GoalScreen();
goalScreen.again_btn.addEventListener(MouseEvent.CLICK, retryLevel);
goalScreen.next_btn.addEventListener(MouseEvent.CLICK, nextLevel);
goalScreen.menu_btn.addEventListener(MouseEvent.CLICK, showMenu);
};
goalScreen.time_tf.text = getTimeString(((levelFinishTime - levelStartTime) - levelPauseLength));
goalScreen.time_tf.autoSize = "center";
goalScreen.best_tf.text = getTimeString(records.data.bestTimes[currentLevel]);
goalScreen.best_tf.autoSize = "center";
addChild(goalScreen);
}
public function getTimeString(_arg1:uint):String{
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
_local2 = (_arg1 / 1000);
_local3 = Math.floor((_local2 / 60));
_local4 = _local3;
if (_local4 < 10){
_local4 = ("0" + _local4);
};
_local5 = (Math.floor(_local2) % 60);
if (_local5 < 10){
_local5 = ("0" + _local5);
};
_local6 = Math.floor(((_local2 % 1) * 100));
if (_local6 < 10){
_local6 = ("0" + _local6);
};
_local7 = ((((_local4 + ":") + _local5) + ".") + _local6);
return (_local7);
}
protected function hideGoalScreen():void{
if (goalScreen.stage){
removeChild(goalScreen);
};
}
protected function rotate(_arg1:MovieClip, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
_local5 = (_arg1.x - _arg2);
_local6 = (_arg1.y - _arg3);
_local7 = rad(_arg4);
_local8 = Math.cos(_local7);
_local9 = Math.sin(_local7);
_arg1.x = (_arg2 + ((_local5 * _local8) - (_local6 * _local9)));
_arg1.y = (_arg3 + ((_local5 * _local9) + (_local6 * _local8)));
_arg1.rotation = (_arg1.rotation + _arg4);
}
public function start():void{
if (!stage){
return;
};
isDown = new Array();
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey);
stage.addEventListener(KeyboardEvent.KEY_UP, onKey);
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.focus = stage;
}
protected function rotateSpace():void{
var _local1:*;
var _local2:*;
var _local3:*;
_local1 = (keyIsDown(Keyboard.RIGHT) - keyIsDown(Keyboard.LEFT));
_local2 = (0.75 + (0.75 * keyIsDown(Keyboard.SPACE)));
_local3 = space.localToGlobal(new Point(ball.x, ball.y));
space.w = (space.w + (_local1 * _local2));
space.w = (space.w * 0.9);
if (!_local1){
space.w = (space.w * 0.7);
};
rotate(space, _local3.x, _local3.y, space.w);
}
protected function moveBall():void{
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
var _local12:*;
var _local13:*;
var _local14:*;
var _local15:*;
var _local16:*;
var _local17:*;
ball.rotation = -(space.rotation);
_local1 = 0.6;
_local2 = rad((90 - space.rotation));
ball.vx = (ball.vx + (_local1 * Math.cos(_local2)));
ball.vy = (ball.vy + (_local1 * Math.sin(_local2)));
_local3 = 0.95;
ball.vx = (ball.vx * _local3);
ball.vy = (ball.vy * _local3);
ball.x = (ball.x + ball.vx);
ball.y = (ball.y + ball.vy);
_local4 = (space.radius - ball.radius);
_local5 = _local4;
_local6 = 0.5;
if (Math.abs(ball.x) > _local4){
ball.x = (sign(ball.x) * _local4);
if (sign(ball.vx) == sign(ball.x)){
ball.vx = (ball.vx * -(_local6));
};
};
if (Math.abs(ball.y) > _local5){
ball.y = (sign(ball.y) * _local5);
if (sign(ball.vy) == sign(ball.y)){
ball.vy = (ball.vy * -(_local6));
};
};
_local7 = new Object();
_local8 = map.getClipsNearPoint(new Point(ball.x, ball.y), ball.radius);
while (_local8.length) {
_local9 = _local8.pop();
if (_local7[_local9.name]){
} else {
_local7[_local9.name] = true;
_local10 = (ball.x - _local9.x);
_local11 = (ball.y - _local9.y);
_local12 = hyp(_local10, _local11);
_local13 = (ball.radius + _local9.radius);
if ((_local9 is Hole)){
_local13 = _local9.radius;
if (_local12 < _local13){
ball.vx = 0;
ball.vy = 0;
_local14 = 5;
ball.tweenX = new Tween(ball, "x", Regular.easeOut, ball.x, _local9.x, _local14);
ball.tweenY = new Tween(ball, "y", Regular.easeOut, ball.y, _local9.y, _local14);
ball.play();
if ((_local9 is Goal)){
ball.completed = true;
levelFinishTime = getTimer();
storeTime(currentLevel, ((levelFinishTime - levelStartTime) - levelPauseLength));
};
pause();
};
} else {
if ((_local9 is Peg)){
if (_local12 < _local13){
_local15 = new R2((ball.x - _local9.x), (ball.y - _local9.y)).unit();
_local16 = new R2(ball.vx, ball.vy);
ball.x = (ball.x + ((_local13 - _local12) * _local15.x));
ball.y = (ball.y + ((_local13 - _local12) * _local15.y));
_local17 = _local16.dot(_local15);
if (_local17 < 0){
_local6 = 1.5;
ball.vx = (ball.vx - ((_local6 * _local17) * _local15.x));
ball.vy = (ball.vy - ((_local6 * _local17) * _local15.y));
};
};
};
};
};
};
}
protected function nextLevel(_arg1:MouseEvent=null):void{
hideGoalScreen();
if (currentLevel < TOTAL_LEVELS){
currentLevel++;
setupLevel();
} else {
parent.showGameOverScreen();
records.data.times = new Array();
};
}
protected function hyp(_arg1:Number, _arg2:Number):Number{
return (Math.sqrt(((_arg1 * _arg1) + (_arg2 * _arg2))));
}
protected function hidePauseScreen():void{
if (pauseScreen.stage){
removeChild(pauseScreen);
};
}
public function getTotalTime():Number{
var _local1:*;
var _local2:uint;
_local1 = 0;
_local2 = 1;
while (_local2 <= TOTAL_LEVELS) {
_local1 = (_local1 + records.data.times[_local2]);
_local2++;
};
return (_local1);
}
public function resumegame():void{
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.focus = stage;
}
protected function panSpace(_arg1:Number=1):Boolean{
var _local2:*;
var _local3:*;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
_local2 = (Math.atan2(ball.y, ball.x) + rad(space.rotation));
_local3 = hyp(ball.x, ball.y);
_local4 = 400;
_local5 = 300;
_local6 = (_local4 - ((space.scaleX * _local3) * Math.cos(_local2)));
_local7 = (_local5 - ((space.scaleY * _local3) * Math.sin(_local2)));
space.x = (space.x + ((_local6 - space.x) / _arg1));
space.y = (space.y + ((_local7 - space.y) / _arg1));
return ((((Math.abs((_local6 - space.x)) < 0.5)) && ((Math.abs((_local7 - space.y)) < 0.5))));
}
protected function storeTime(_arg1, _arg2):void{
var _local3:*;
records.data.times[_arg1] = _arg2;
_local3 = records.data.bestTimes[_arg1];
if ((((_local3 == undefined)) || ((_local3 > _arg2)))){
records.data.bestTimes[_arg1] = _arg2;
};
}
protected function explore():void{
ball.visible = false;
if (keyIsDown(Keyboard.SPACE)){
exploreMode = "tween";
};
if (exploreMode == "tween"){
hideStartScreen();
ball.visible = true;
if (panSpace(5)){
exploreMode = "off";
};
};
}
protected function onEnterFrame(_arg1:Event):void{
if (exploreMode == "off"){
if (gamePaused == false){
rotateSpace();
moveBall();
zoomSpace();
panSpace();
};
} else {
explore();
};
}
protected function sign(_arg1:Number):int{
if (!_arg1){
return (1);
};
return ((_arg1 / Math.abs(_arg1)));
}
protected function setRadius(_arg1:MovieClip):void{
if (_arg1.hit_mc){
_arg1.radius = ((_arg1.scaleX * _arg1.hit_mc.width) / 2);
_arg1.hit_mc.visible = false;
} else {
_arg1.radius = (_arg1.width / 2);
};
}
protected function retryLevel(_arg1:MouseEvent=null):void{
hideGoalScreen();
setupLevel();
}
protected function showPauseScreen():void{
if (!pauseScreen){
pauseScreen = new PauseScreen();
};
addChild(pauseScreen);
}
protected function hideStartScreen():void{
if (startScreen.stage){
removeChild(startScreen);
};
}
public function pausegame():void{
if (!stage){
return;
};
stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(Event.ENTER_FRAME, checkForResume);
}
protected function resetBall(){
if (ball.tweenX){
ball.tweenX.stop();
};
if (ball.tweenY){
ball.tweenY.stop();
};
ball.x = startMarker.x;
ball.y = startMarker.y;
ball.vx = (ball.vy = 0);
ball.gotoAndStop(1);
ball.completed = false;
space.rotation = 0;
space.scaleX = (space.scaleY = 0.5);
space.w = 0;
if (exploreMode == "off"){
panSpace();
} else {
space.x = 400;
space.y = 300;
};
start();
}
public function pause():void{
if (!stage){
return;
};
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKey);
stage.removeEventListener(KeyboardEvent.KEY_UP, onKey);
stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}//package
Section 19
//GameOverScreen (GameOverScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class GameOverScreen extends MovieClip {
public var time_tf:TextField;
public var name_tf:TextField;
public var submit_btn:SimpleButton;
}
}//package
Section 20
//Goal (Goal)
package {
public dynamic class Goal extends Hole {
}
}//package
Section 21
//GoalScreen (GoalScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class GoalScreen extends MovieClip {
public var next_btn:SimpleButton;
public var time_tf:TextField;
public var menu_btn:SimpleButton;
public var best_tf:TextField;
public var again_btn:SimpleButton;
}
}//package
Section 22
//Hole (Hole)
package {
import flash.display.*;
public class Hole extends MovieClip {
public var radius:Number;
public var hit_mc:MovieClip;
public function Hole():void{
}
}
}//package
Section 23
//Level1 (Level1)
package {
import flash.display.*;
public dynamic class Level1 extends MovieClip {
}
}//package
Section 24
//Level10 (Level10)
package {
import flash.display.*;
public dynamic class Level10 extends MovieClip {
}
}//package
Section 25
//Level11 (Level11)
package {
import flash.display.*;
public dynamic class Level11 extends MovieClip {
}
}//package
Section 26
//Level2 (Level2)
package {
import flash.display.*;
public dynamic class Level2 extends MovieClip {
}
}//package
Section 27
//Level3 (Level3)
package {
import flash.display.*;
public dynamic class Level3 extends MovieClip {
}
}//package
Section 28
//Level4 (Level4)
package {
import flash.display.*;
public dynamic class Level4 extends MovieClip {
}
}//package
Section 29
//Level5 (Level5)
package {
import flash.display.*;
public dynamic class Level5 extends MovieClip {
}
}//package
Section 30
//Level6 (Level6)
package {
import flash.display.*;
public dynamic class Level6 extends MovieClip {
}
}//package
Section 31
//Level7 (Level7)
package {
import flash.display.*;
public dynamic class Level7 extends MovieClip {
}
}//package
Section 32
//Level8 (Level8)
package {
import flash.display.*;
public dynamic class Level8 extends MovieClip {
}
}//package
Section 33
//Level9 (Level9)
package {
import flash.display.*;
public dynamic class Level9 extends MovieClip {
}
}//package
Section 34
//PauseScreen (PauseScreen)
package {
import flash.display.*;
public dynamic class PauseScreen extends MovieClip {
}
}//package
Section 35
//Peg (Peg)
package {
import flash.display.*;
public class Peg extends MovieClip {
public var radius:Number;
public var hit_mc:MovieClip;
public function Peg():void{
}
}
}//package
Section 36
//R2 (R2)
package {
import flash.geom.*;
public class R2 extends Point {
public function R2(_arg1:Number=0, _arg2:Number=0):void{
this.x = _arg1;
this.y = _arg2;
}
public function cross(_arg1:R2):Number{
return (((x * _arg1.y) - (y * _arg1.x)));
}
public function mag():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function sum(_arg1:R2):R2{
return (new R2((x + _arg1.x), (y + _arg1.y)));
}
public function unit():R2{
var _local1:*;
_local1 = mag();
return (new R2((x / _local1), (y / _local1)));
}
public function dot(_arg1:R2):Number{
return (((x * _arg1.x) + (y * _arg1.y)));
}
public function scale(_arg1:Number):R2{
return (new R2((_arg1 * x), (_arg1 * y)));
}
public function perp():R2{
return (new R2(-(y), x));
}
}
}//package
Section 37
//Spinball (Spinball)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.media.*;
public class Spinball extends MovieClip {
public var hsLoader:Loader;
public var continueScreen:MovieClip;
public var music:SoundChannel;
public var game:MovieClip;
public var titleScreen:MovieClip;
public var soundToggle:MovieClip;
public var hsConnection:LocalConnection;
public var hsInfo:Object;
public var gameOverScreen:MovieClip;
public var menuBtn:MovieClip;
public var loadScreen:MovieClip;
public function Spinball():void{
stop();
preload();
}
public function preload():void{
loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
loaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
soundToggle.visible = false;
menuBtn.visible = false;
}
public function startMusic():void{
if (music){
return;
};
if (soundToggle.currentLabel == "OFF"){
return;
};
music = new Sound(new URLRequest("spinball.mp3")).play(0, 1000);
}
public function toggleSound(_arg1:MouseEvent):void{
if (soundToggle.currentLabel == "ON"){
stopMusic();
soundToggle.gotoAndStop("OFF");
} else {
soundToggle.gotoAndStop("ON");
startMusic();
};
}
public function onClickGameOver(_arg1:MouseEvent):void{
switch (_arg1.target){
case gameOverScreen.submit_btn:
submitScore();
break;
};
}
public function menubtn_over(_arg1:MouseEvent):void{
_arg1.target.gotoAndStop("OVER");
}
public function playSound(_arg1:String, _arg2:Number=1):void{
var _local3:*;
var _local4:*;
var _local5:*;
_local3 = getDefinitionByName(_arg1);
if (_local3){
_local4 = new (_local3).play();
_local5 = new SoundTransform();
_local5.volume = _arg2;
_local4.soundTransform = _local5;
};
}
public function stopMusic():void{
if (!music){
return;
};
music.stop();
music = null;
}
public function showContinueScreen():void{
continueScreen = new ContinueScreen();
continueScreen.addEventListener(MouseEvent.CLICK, onClickContinue);
}
public function submitScore():void{
var _local1:String;
_local1 = gameOverScreen.name_tf.text;
hsConnection.send("lc_example", "subscor", 590, _local1, hsInfo.ms, 0, hsInfo.t);
showTitleScreen();
}
public function showGameOverScreen():void{
gameOverScreen = new GameOverScreen();
gameOverScreen.time_tf.text = game.getTimeString(game.getTotalTime());
gameOverScreen.time_tf.autoSize = "center";
gameOverScreen.time_tf.restrict = "a-zA-Z0-9";
addChild(gameOverScreen);
gameOverScreen.addEventListener(MouseEvent.CLICK, onClickGameOver);
stage.focus = gameOverScreen.name_tf;
hsInfo = new Object();
hsInfo.ms = game.getTotalTime();
hsInfo.t = game.getTimeString(hsInfo.ms);
}
public function goToMenu(_arg1:MouseEvent):void{
showTitleScreen();
}
public function menubtn_up(_arg1:MouseEvent):void{
_arg1.target.gotoAndStop("UP");
}
public function clearScreens():void{
stopMusic();
if (soundToggle){
soundToggle.visible = false;
};
if (((titleScreen) && (titleScreen.stage))){
titleScreen.removeEventListener(MouseEvent.CLICK, onClickTitle);
removeChild(titleScreen);
titleScreen = null;
};
if (((game) && (game.stage))){
removeChild(game);
game = null;
};
if (((gameOverScreen) && (gameOverScreen.stage))){
gameOverScreen.removeEventListener(MouseEvent.CLICK, onClickGameOver);
removeChild(gameOverScreen);
gameOverScreen = null;
};
if (((continueScreen) && (continueScreen.stage))){
continueScreen.removeEventListener(MouseEvent.CLICK, onClickContinue);
removeChild(continueScreen);
continueScreen = null;
};
}
public function onClickContinue(_arg1:MouseEvent):void{
switch (_arg1.target){
case continueScreen.continue_btn:
case continueScreen.new_btn:
break;
};
}
public function showGame(_arg1:uint=1):void{
clearScreens();
startMusic();
game = new Game();
game.currentLevel = _arg1;
game.setupLevel();
addChildAt(game, 0);
game.start();
soundToggle.visible = true;
menuBtn.visible = true;
}
public function onLoadComplete(_arg1:Event):void{
loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
loaderInfo.removeEventListener(Event.COMPLETE, onLoadComplete);
gotoAndStop("MAIN");
showTitleScreen();
soundToggle.addEventListener(MouseEvent.MOUSE_DOWN, toggleSound);
soundToggle.buttonMode = true;
menuBtn.addEventListener(MouseEvent.MOUSE_DOWN, goToMenu);
menuBtn.addEventListener(MouseEvent.MOUSE_OVER, menubtn_over);
menuBtn.addEventListener(MouseEvent.MOUSE_OUT, menubtn_up);
menuBtn.buttonMode = true;
hsConnection = new LocalConnection();
hsLoader = new Loader();
hsLoader.load(new URLRequest("/kids/games/loader2.swf"));
}
public function onLoadProgress(_arg1:ProgressEvent):void{
var _local2:*;
_local2 = (loaderInfo.bytesLoaded / loaderInfo.bytesTotal);
}
public function showTitleScreen():void{
var _local1:*;
clearScreens();
titleScreen = new TitleScreen();
addChild(titleScreen);
titleScreen.addEventListener(MouseEvent.CLICK, onClickTitle);
_local1 = SharedObject.getLocal(Game.sharedObjectID);
if (((!(_local1.data.times)) || (!(_local1.data.times.length)))){
titleScreen.continue_btn.mouseEnabled = false;
titleScreen.continue_btn.alpha = 0.5;
};
}
public function setMusicVolume(_arg1:Number):void{
var _local2:*;
if (!music){
return;
};
_local2 = new SoundTransform();
_local2.volume = _arg1;
music.soundTransform = _local2;
}
public function onClickTitle(_arg1:MouseEvent):void{
var _local2:*;
var _local3:*;
var _local4:*;
if (_arg1.target == titleScreen.new_btn){
showGame();
} else {
if (_arg1.target == titleScreen.continue_btn){
_local2 = SharedObject.getLocal(Game.sharedObjectID);
_local3 = _local2.data.times;
_local4 = Math.min(_local3.length, Game.TOTAL_LEVELS);
showGame(_local4);
};
};
}
}
}//package
Section 38
//StartMarker (StartMarker)
package {
import flash.display.*;
public dynamic class StartMarker extends MovieClip {
}
}//package
Section 39
//StartScreen (StartScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class StartScreen extends MovieClip {
public var level_tf:TextField;
}
}//package
Section 40
//TitleScreen (TitleScreen)
package {
import flash.display.*;
public dynamic class TitleScreen extends MovieClip {
public var new_btn:SimpleButton;
public var continue_btn:SimpleButton;
}
}//package
Section 41
//Trap (Trap)
package {
public dynamic class Trap extends Hole {
}
}//package