Frame 1
Main.initialize(this);
Symbol 5 MovieClip [line] Frame 1
#initclip 17
Object.registerClass("line", Line);
#endinitclip
Symbol 12 MovieClip [winDialog] Frame 1
#initclip 9
Object.registerClass("winDialog", WinDialog);
#endinitclip
Symbol 12 MovieClip [winDialog] Frame 35
winFinished();
Symbol 18 MovieClip [message] Frame 1
#initclip 10
Object.registerClass("message", Message);
#endinitclip
Symbol 20 MovieClip [house] Frame 1
#initclip 11
Object.registerClass("house", Thing);
#endinitclip
Symbol 22 MovieClip [supplyGas] Frame 1
#initclip 12
Object.registerClass("supplyGas", Thing);
#endinitclip
Symbol 24 MovieClip [supplyElectricity] Frame 1
#initclip 13
Object.registerClass("supplyElectricity", Thing);
#endinitclip
Symbol 26 MovieClip [supplyWater] Frame 1
#initclip 14
Object.registerClass("supplyWater", Thing);
#endinitclip
Symbol 45 MovieClip [game] Frame 1
#initclip 15
Object.registerClass("game", Game);
#endinitclip
Symbol 54 MovieClip [splash] Frame 1
#initclip 16
Object.registerClass("splash", Splash);
#endinitclip
Symbol 54 MovieClip [splash] Frame 45
finished();
Symbol 61 MovieClip [__Packages.Main] Frame 0
class Main extends MovieClip
{
var gotoAndStop, startButton, getURL, unloadMovie;
function Main () {
super();
}
static function initialize(movieClip) {
movieClip.__proto__ = Main.prototype;
movieClip.init();
}
function init() {
gotoSplashPage();
}
function gotoSplashPage() {
(gotoAndStop("splash"));// not popped
}
function gotoTitlePage() {
(gotoAndStop("title"));// not popped
startButton.onRelease = function () {
this._parent.gotoGamePage();
};
}
function gotoGamePage() {
(gotoAndStop("game"));// not popped
}
function checkWebSite() {
var _local3 = Config.SITE.length;
if (((this != _root) || (_root != _level0)) || (_level0._url.substr(0, _local3) != Config.SITE)) {
(getURL(Config.SITE));// not popped
(unloadMovie());// not popped
}
}
}
Symbol 62 MovieClip [__Packages.Config] Frame 0
class Config
{
function Config () {
}
static var LINES_MINX = 0;
static var LINES_MAXX = 600;
static var LINES_MINY = 0;
static var LINES_MAXY = 320;
static var LINES_THICKNESS = 2;
static var LINES_COLOURS = [255, 65280, 16750848];
static var LINES_DRAWINGCOLOUR = 10066329;
static var LINES_WRONGCOLOUR = 16711680;
static var LINES_POINTSSPACING = 1;
static var MESSAGE_DISTANCEFROMPOINT = 120;
static var MESSAGE_SHOWTIME = 1500;
static var SITE = "http://www.supuzzle.com";
}
Symbol 63 MovieClip [__Packages.WinDialog] Frame 0
class WinDialog extends MovieClip
{
var stop, gotoAndPlay, playAgainButton;
function WinDialog () {
super();
(stop());// not popped
}
function showWin() {
(gotoAndPlay("win"));// not popped
}
function winFinished() {
(stop());// not popped
playAgainButton.onRelease = function () {
this._parent._parent._parent.gotoTitlePage();
};
}
}
Symbol 64 MovieClip [__Packages.Message] Frame 0
class Message extends MovieClip
{
var stop, gotoAndStop, arrow, _x, _y, intervalID;
function Message () {
super();
(stop());// not popped
}
function show(type, x, y) {
var _local4 = (Config.LINES_MINX + Config.LINES_MAXX) / 2;
var _local3 = (Config.LINES_MINY + Config.LINES_MAXY) / 2;
var _local2 = Math.atan2(y - _local3, x - _local4);
switch (type) {
case TYPE_CROSS :
(gotoAndStop("cross"));// not popped
break;
case TYPE_DUPLICATE :
(gotoAndStop("duplicate"));// not popped
break;
case TYPE_INVALID :
(gotoAndStop("invalid"));// not popped
}
arrow._rotation = (_local2 * 180) / Math.PI;
_x = x - (Math.cos(_local2) * Config.MESSAGE_DISTANCEFROMPOINT);
_y = y - (Math.sin(_local2) * Config.MESSAGE_DISTANCEFROMPOINT);
clearInterval(intervalID);
intervalID = setInterval(this, "hide", Config.MESSAGE_SHOWTIME);
}
function hide() {
clearInterval(intervalID);
(gotoAndStop("hide"));// not popped
}
static var TYPE_CROSS = 1;
static var TYPE_DUPLICATE = 2;
static var TYPE_INVALID = 3;
}
Symbol 65 MovieClip [__Packages.Thing] Frame 0
class Thing extends MovieClip
{
var stop, gotoAndStop;
function Thing () {
super();
(stop());// not popped
}
function highlight() {
(gotoAndStop("highlight"));// not popped
}
function unhighlight() {
(gotoAndStop("normal"));// not popped
}
static var TYPE_HOUSE = 1;
static var TYPE_SUPPLY = 2;
}
Symbol 66 MovieClip [__Packages.Game] Frame 0
class Game extends MovieClip
{
var lines, things, houses, supplies, urlButton, undoButton, resetButton, soundStart, soundConnect, soundWrong, soundWin, pencil, onMouseMove, onMouseDown, onMouseUp, linesHolder, drawingLine, _xmouse, _ymouse, message, winDialog;
function Game () {
super();
var _local3;
lines = new Array();
things = new Array();
houses = new Array();
_local3 = 0;
while (this["house" + _local3]) {
houses[_local3] = this["house" + _local3];
houses[_local3].type = Thing.TYPE_HOUSE;
houses[_local3].index = _local3;
things.push(houses[_local3]);
_local3++;
}
supplies = new Array();
_local3 = 0;
while (this["supply" + _local3]) {
supplies[_local3] = this["supply" + _local3];
supplies[_local3].type = Thing.TYPE_SUPPLY;
supplies[_local3].index = _local3;
things.push(supplies[_local3]);
_local3++;
}
urlButton.onRelease = function () {
this._parent.getURL(Config.SITE, "_blank");
};
undoButton.onRelease = function () {
this._parent.undo();
};
resetButton.onRelease = function () {
this._parent.reset();
};
soundStart = new Sound(this);
soundConnect = new Sound(this);
soundWrong = new Sound(this);
soundWin = new Sound(this);
soundStart.attachSound("soundStart");
soundConnect.attachSound("soundConnect");
soundWrong.attachSound("soundWrong");
soundWin.attachSound("soundWin");
startNormal();
}
function startNormal() {
pencil._visible = false;
pencil.stopDrag();
Mouse.show();
onMouseMove = onNormalMouseMove;
onMouseDown = onNormalMouseDown;
onMouseUp = null;
}
function onNormalMouseMove() {
var _local3;
var _local2;
_local2 = 0;
while (_local2 < things.length) {
things[_local2].unhighlight();
_local2++;
}
_local3 = getMouseOverThing();
if (getLinesCanBeAddedToThing(_local3)) {
_local3.highlight();
}
updateAfterEvent();
}
function onNormalMouseDown() {
var _local2 = getMouseOverThing();
var _local3;
var _local4;
var _local5;
if (!_local2) {
return(undefined);
}
if (!getLinesCanBeAddedToThing(_local2)) {
return(undefined);
}
_local3 = linesHolder.getNextHighestDepth();
_local4 = linesHolder.attachMovie("line", "line" + _local3, _local3);
drawingLine = _local4;
drawingLine.initialize(_xmouse, _ymouse, _local2);
Mouse.hide();
pencil._visible = true;
pencil.startDrag(true, Config.LINES_MINX, Config.LINES_MINY, Config.LINES_MAXX, Config.LINES_MAXY);
pencil._x = _xmouse;
pencil._y = _ymouse;
onMouseMove = onDrawingMouseMove;
onMouseDown = null;
onMouseUp = onDrawingMouseUp;
soundStart.start();
}
function onDrawingMouseMove() {
var _local4 = getMouseOverThing();
var _local5;
var _local3;
var _local2;
onNormalMouseMove();
_local5 = drawingLine.points.length;
if (_xmouse < Config.LINES_MINX) {
_local3 = Config.LINES_MINX;
} else if (_xmouse > Config.LINES_MAXX) {
_local3 = Config.LINES_MAXX;
} else {
_local3 = _xmouse;
}
if (_ymouse < Config.LINES_MINY) {
_local2 = Config.LINES_MINY;
} else if (_ymouse > Config.LINES_MAXY) {
_local2 = Config.LINES_MAXY;
} else {
_local2 = _ymouse;
}
drawingLine.update(_local3, _local2);
if (getLineCrossesOtherLines(drawingLine, _local5)) {
drawingLine.setWrong();
soundWrong.start();
message.show(Message.TYPE_CROSS, _local3, _local2);
}
if (_local4 && (_local4 != drawingLine.beginThing)) {
onDrawingMouseUp();
}
updateAfterEvent();
}
function onDrawingMouseUp() {
var _local2 = getMouseOverThing();
var _local3;
if (!_local2) {
drawingLine.removeMovieClip();
startNormal();
return(undefined);
}
_local2.unhighlight();
_local3 = drawingLine.points.length;
drawingLine.update(_xmouse, _ymouse);
drawingLine.endThing = _local2;
if (getLineCrossesOtherLines(drawingLine, _local3)) {
drawingLine.setWrong();
soundWrong.start();
message.show(Message.TYPE_CROSS, _xmouse, _ymouse);
} else if (getSameLineExists(drawingLine)) {
drawingLine.setWrong();
soundWrong.start();
message.show(Message.TYPE_DUPLICATE, _xmouse, _ymouse);
} else if ((drawingLine.beginThing.type == drawingLine.endThing.type) || (!getLinesCanBeAddedToThing(drawingLine.endThing))) {
drawingLine.setWrong();
soundWrong.start();
message.show(Message.TYPE_INVALID, _xmouse, _ymouse);
} else if (!drawingLine.isWrong) {
drawingLine.setSupplyColour();
soundConnect.start();
}
lines.push(drawingLine);
if (checkWin()) {
onMouseMove = null;
onMouseDown = null;
onMouseUp = null;
pencil._visible = false;
pencil.stopDrag();
Mouse.show();
undoButton._visible = false;
resetButton._visible = false;
winDialog.showWin();
soundWin.start();
} else {
startNormal();
}
}
function getLinesCanBeAddedToThing(thing) {
var _local5 = ((thing.type == Thing.TYPE_HOUSE) ? (supplies) : (houses));
var _local3 = new Array(_local5.length);
var _local2;
_local2 = 0;
while (_local2 < _local3.length) {
_local3[_local2] = false;
_local2++;
}
_local2 = 0;
for ( ; _local2 < lines.length ; _local2++) {
if (lines[_local2].isWrong) {
} else if (lines[_local2].beginThing == thing) {
if (lines[_local2].endThing.type == thing.type) {
continue;
}
_local3[lines[_local2].endThing.index] = true;
} else if (lines[_local2].endThing == thing) {
if (lines[_local2].beginThing.type == thing.type) {
} else {
_local3[lines[_local2].beginThing.index] = true;
}
}
}
_local2 = 0;
while (_local2 < _local3.length) {
if (!_local3[_local2]) {
return(true);
}
_local2++;
}
return(false);
}
function getSameLineExists(line) {
var _local2;
_local2 = 0;
while (_local2 < lines.length) {
if (lines[_local2] == line) {
} else if (lines[_local2].isWrong) {
} else {
if ((lines[_local2].beginThing == line.beginThing) && (lines[_local2].endThing == line.endThing)) {
return(true);
}
if ((lines[_local2].beginThing == line.endThing) && (lines[_local2].endThing == line.beginThing)) {
return(true);
}
}
_local2++;
}
return(false);
}
function getMouseOverThing() {
return(getPointOverThing(new flash.geom.Point(Math.round(_xmouse / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING, Math.round(_ymouse / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING)));
}
function getPointOverThing(point) {
var _local2;
_local2 = 0;
while (_local2 < things.length) {
if (!things[_local2].hitTest(point.x, point.y, true)) {
} else {
return(things[_local2]);
}
_local2++;
}
return(null);
}
function getLineCrossesOtherLines(line, beginIndex) {
var _local3;
var _local2;
var _local4;
_local3 = beginIndex;
while (_local3 < line.points.length) {
if (getPointOverThing(line.points[_local3])) {
} else {
_local2 = 0;
while (_local2 < lines.length) {
if (lines[_local2].getHasPoint(line.points[_local3])) {
return(true);
}
_local2++;
}
}
_local3++;
}
return(false);
while (_local3 < lines.length) {
if (lines[_local3] == line) {
} else {
_local2 = beginIndex;
while (_local2 < line.points.length) {
if (getPointOverThing(line.points[_local2])) {
} else {
_local4 = 0;
while (_local4 < lines[_local3].points.length) {
if ((line.points[_local2].x == lines[_local3].points[_local4].x) && (line.points[_local2].y == lines[_local3].points[_local4].y)) {
return(true);
}
_local4++;
}
}
_local2++;
}
}
_local3++;
}
return(false);
}
function undo() {
lines[lines.length - 1].removeMovieClip();
lines.pop();
}
function reset() {
var _local2;
_local2 = 0;
while (_local2 < lines.length) {
lines[_local2].removeMovieClip();
_local2++;
}
lines = new Array();
}
function checkWin() {
var _local3;
var _local4;
var _local2;
_local4 = 0;
while (_local4 < lines.length) {
if (lines[_local4].isWrong) {
return(false);
}
_local4++;
}
_local3 = new Array(supplies.length);
_local4 = 0;
while (_local4 < houses.length) {
_local2 = 0;
while (_local2 < _local3.length) {
_local3[_local2] = false;
_local2++;
}
_local2 = 0;
while (_local2 < lines.length) {
if (lines[_local2].beginThing == houses[_local4]) {
_local3[lines[_local2].endThing.index] = true;
} else if (lines[_local2].endThing == houses[_local4]) {
_local3[lines[_local2].beginThing.index] = true;
}
_local2++;
}
_local2 = 0;
while (_local2 < _local3.length) {
if (!_local3[_local2]) {
return(false);
}
_local2++;
}
_local4++;
}
return(true);
}
}
Symbol 67 MovieClip [__Packages.Line] Frame 0
class Line extends MovieClip
{
var beginThing, isWrong, points, lineStyle, moveTo, pointExists, lineTo, clear, endThing;
function Line () {
super();
}
function initialize(x, y, beginThing) {
x = Math.round(x / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING;
y = Math.round(y / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING;
this.beginThing = beginThing;
isWrong = false;
points = new Array();
points.push(new flash.geom.Point(x, y));
lineStyle(Config.LINES_THICKNESS, Config.LINES_DRAWINGCOLOUR);
moveTo(x, y);
pointExists = new Array();
pointExists[x] = new Array();
pointExists[x][y] = true;
}
function update(x, y) {
var _local9;
var _local8;
var _local6;
var _local10;
var _local11;
var _local3;
var _local2;
var _local4;
var _local7;
var _local5;
x = Math.round(x / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING;
y = Math.round(y / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING;
_local9 = x - points[points.length - 1].x;
_local8 = y - points[points.length - 1].y;
if ((_local9 == 0) && (_local8 == 0)) {
return(undefined);
}
_local6 = Math.max(Math.abs(_local9), Math.abs(_local8));
_local10 = points[points.length - 1].x;
_local11 = points[points.length - 1].y;
_local4 = _local10;
_local7 = _local11;
_local5 = 0;
while (_local5 < _local6) {
_local3 = _local10 + (Math.round(((_local9 * (_local5 + Config.LINES_POINTSSPACING)) / _local6) / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING);
_local2 = _local11 + (Math.round(((_local8 * (_local5 + Config.LINES_POINTSSPACING)) / _local6) / Config.LINES_POINTSSPACING) * Config.LINES_POINTSSPACING);
if ((_local3 != _local4) && (_local2 != _local7)) {
lineTo(_local4, _local2);
points.push(new flash.geom.Point(_local4, _local2));
if (!pointExists[_local4]) {
pointExists[_local4] = new Array();
}
pointExists[_local4][_local2] = true;
}
lineTo(_local3, _local2);
points.push(new flash.geom.Point(_local3, _local2));
if (!pointExists[_local3]) {
pointExists[_local3] = new Array();
}
pointExists[_local3][_local2] = true;
_local4 = _local3;
_local7 = _local2;
_local5 = _local5 + Config.LINES_POINTSSPACING;
}
}
function setWrong() {
isWrong = true;
setWrongColour();
}
function setWrongColour() {
var _local2;
clear();
lineStyle(Config.LINES_THICKNESS, Config.LINES_WRONGCOLOUR);
moveTo(points[0].x, points[0].y);
_local2 = 1;
while (_local2 < points.length) {
lineTo(points[_local2].x, points[_local2].y);
_local2++;
}
}
function setSupplyColour() {
var _local3;
var _local2;
if (beginThing.type == Thing.TYPE_SUPPLY) {
_local3 = Config.LINES_COLOURS[beginThing.index];
} else {
_local3 = Config.LINES_COLOURS[endThing.index];
}
clear();
lineStyle(Config.LINES_THICKNESS, _local3);
moveTo(points[0].x, points[0].y);
_local2 = 1;
while (_local2 < points.length) {
lineTo(points[_local2].x, points[_local2].y);
_local2++;
}
}
function getHasPoint(point) {
if (pointExists[point.x][point.y]) {
return(true);
}
return(false);
}
}
Symbol 68 MovieClip [__Packages.Splash] Frame 0
class Splash extends MovieClip
{
var urlButton, stop, _parent;
function Splash () {
super();
urlButton.onRelease = function () {
this._parent.getURL(Config.SITE, "_blank");
};
}
function finished() {
(stop());// not popped
_parent.gotoTitlePage();
}
}