Frame 1
function crayon(hexColor) {
this.hexColor = hexColor;
crayons.push(this);
}
function texture() {
this.createOverlay();
this.mID = textures.length;
textures.push(this);
return(this);
}
function deactivateAllTexturesBut(skipMe) {
var _local1 = 0;
while (_local1 < textures.length) {
if (_local1 != skipMe) {
textures[_local1].setActive(false);
}
_local1++;
}
}
function paintWithMouse() {
if (painting && (hitArea_mc.hitTest(_xmouse, _ymouse, true))) {
this.drawRandomCircle(this._xmouse, this._ymouse, 4, 4, crayons[gCurrentColor].hexColor, 80);
}
}
function initialize() {
prompt_mc._visible = false;
prompt_mc._btn.enabled = false;
Key.removeListener(keyListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
a = Key.getCode();
if (a == 32) {
spacePressed();
return(true);
}
trace("Maybe number key pressed: " + a);
var _local1 = 0;
while (_local1 < textures.length) {
if ((a - 49) == _local1) {
trace("Number key pressed: " + _local1);
gCurrentColor = _local1;
}
_local1++;
}
};
Key.addListener(keyListener);
textures = new Array();
attachClipCounter = 0;
}
function spacePressed() {
trace("spacePressed(): called");
gCurrentColor++;
if (gCurrentColor >= crayons.length) {
gCurrentColor = 0;
}
}
function crayonChosen(crayonNumber) {
hideAllIndicators();
eval ("crayon_ind" + crayonNumber)._visible = true;
eval ("crayon_ind" + crayonNumber).gotoAndPlay(1);
gCurrentColor = crayonNumber;
}
function printButtonPressed(printAllChoice) {
printAllPages = printAllChoice;
if (drawnAnything) {
cover_mc.cover_buttons_mc._visible = false;
prompt_mc._visible = true;
buttons_mc._visible = false;
} else {
printPage(printAllChoice);
}
}
function printPage(allPages, printStuff) {
trace("printPage(): called");
var _local6 = new PrintJob();
if (_local6.start()) {
var _local8 = 0;
buttons_mc._visible = false;
trace((("parentClip" + parentClip_mc._x) + ",") + parentClip_mc._y);
_root._rotation = 90;
trace((("parentClip" + parentClip_mc._x) + ",") + parentClip_mc._y);
_root._xscale = 131;
_root._yscale = 131;
if (!allPages) {
trace("allPages = false");
trace((((((("printPage(): " + hitArea_mc._x) + ",") + hitArea_mc._width) + ",") + hitArea_mc._y) + ",") + hitArea_mc._height);
if (!printStuff) {
textures[activeTexture].overlayClip._visible = false;
}
if (_local6.addPage(0, {xMin:-20, xMax:550, yMin:-30, yMax:410})) {
_local8++;
}
textures[activeTexture].overlayClip._visible = true;
} else {
trace("allPages = true");
var _local10 = activeTexture;
cover_mc._visible = false;
var _local2 = 0;
while (_local2 < lines_mc._totalframes) {
textures[_local2].setActive(true);
lines_mc.gotoAndStop(Number(_local2 + 1));
if (!printStuff) {
textures[_local2].overlayClip._visible = false;
}
if (_local6.addPage(0, {xMin:-20, xMax:550, yMin:-30, yMax:410})) {
_local8++;
}
textures[_local2].overlayClip._visible = true;
_local2++;
}
textures[_local10].setActive(true);
lines_mc.gotoAndStop(1);
cover_mc._visible = true;
}
buttons_mc._visible = true;
_root._rotation = 0;
_root._xscale = 100;
_root._yscale = 100;
if (_local8 > 0) {
_local6.send();
}
}
new_mc.removeMovieClip();
}
function promptChoice(printStuff) {
cover_mc.cover_buttons_mc._visible = true;
prompt_mc._visible = false;
buttons_mc._visible = true;
printPage(printAllPages, printStuff);
}
function undo() {
if (textures[activeTexture].depthCounter == 0) {
return(undefined);
}
trace((("undo() called" + activeTexture) + textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter)) + textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 1));
if (!undoState) {
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter)._visible = false;
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 1)._visible = true;
} else {
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter)._visible = true;
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 1)._visible = false;
}
undoState = !undoState;
}
function colorPage() {
this.mID = colorPages.length;
this.textureObj = new texture();
this.textureObj.setActive(false);
colorPages.push(this);
}
function navButtonPressed(forward) {
var _local3 = currentColorPage;
trace((((("navButtonPressed(" + forward) + "): called before ") + this._totalframes) + " ") + currentColorPage);
if (forward) {
currentColorPage++;
if (currentColorPage >= lines_mc._totalframes) {
currentColorPage = 0;
cover_mc._visible = true;
}
} else {
currentColorPage--;
if (currentColorPage < 0) {
currentColorPage = 0;
cover_mc._visible = true;
}
}
lines_mc.gotoAndStop(Number(currentColorPage + 1));
colorPages[currentColorPage].setActive();
trace((((("navButtonPressed(" + forward) + "): called after ") + this._totalframes) + " ") + currentColorPage);
}
function hideAllIndicators() {
var i = 0;
while (i < crayons.length) {
eval ("crayon_ind" + i)._visible = false;
i++;
}
}
function clearCurrentPage() {
trace("clearCurrentPage(): called");
colorPages[currentColorPage].clear();
}
function coverPressed() {
cover_mc._visible = false;
}
function setBook() {
var _local2 = 0;
new crayon(0);
new crayon(65280);
new crayon(3368703);
new crayon(16430286);
new crayon(7687936);
new crayon(10040268);
new crayon(16711680);
new crayon(16777062);
var _local1 = 0;
while (_local1 < lines_mc._totalframes) {
new colorPage();
_local1++;
}
hideAllIndicators();
crayonChosen(0);
colorPages[0].setActive(true);
}
var gCurrentColor = 0;
var attachClipCounter = 0;
var painting = false;
var textures = new Array();
var activeTexture;
var keyListener;
var crayons = new Array();
var printAllPages = false;
var drawnAnything = false;
var undoState = false;
MovieClip.prototype.drawCircle = function (x, y, r, RGB, alpha) {
trace("drawCircle for " + this._name);
this.moveTo(x + r, y);
this.beginFill(RGB);
this.curveTo(r + x, (0.414213562373095 * r) + y, (0.707106781186547 * r) + x, (0.707106781186547 * r) + y);
this.curveTo((0.414213562373095 * r) + x, r + y, x, r + y);
this.curveTo((-0.414213562373095 * r) + x, r + y, (-0.707106781186547 * r) + x, (0.707106781186547 * r) + y);
this.curveTo((-r) + x, (0.414213562373095 * r) + y, (-r) + x, y);
this.curveTo((-r) + x, (-0.414213562373095 * r) + y, (-0.707106781186547 * r) + x, (-0.707106781186547 * r) + y);
this.curveTo((-0.414213562373095 * r) + x, (-r) + y, x, (-r) + y);
this.curveTo((0.414213562373095 * r) + x, (-r) + y, (0.707106781186547 * r) + x, (-0.707106781186547 * r) + y);
this.curveTo(r + x, (-0.414213562373095 * r) + y, r + x, y);
};
MovieClip.prototype.drawRandomCircle = function (x, y, w_topbound, h_topbound, RGB, alpha) {
var _local2 = (Math.random() * (w_topbound - 2)) + 2;
this.drawCircle(x, y, _local2, RGB, alpha);
trace((("drawRandomCircle" + this._name) + ",") + this.mOverlay._name);
this.mOverlay.drawCircle(x, y, _local2, RGB, alpha);
};
texture.prototype.createOverlay = function () {
trace("createOverlay() called");
this.depthCounter = 0;
this.overlayClip = parentClip_mc.createEmptyMovieClip("overlayClip_mc" + attachClipCounter, attachClipCounter++);
this.overlayClip.createEmptyMovieClip("overlay" + this.depthCounter, this.depthCounter);
trace("createOverlay:: " + this.depthCounter);
this.overlayClip._alpha = 80;
};
texture.prototype.clear = function () {
this.overlayClip.removeMovieClip();
this.createOverlay();
crayonChosen(gCurrentColor);
};
texture.prototype.getOverlayClip = function (num) {
if (num == undefined) {
return(this.overlayClip["overlay" + this.depthCounter]);
}
return(this.overlayClip["overlay" + num]);
};
texture.prototype.setVisible = function (visibleValue) {
this.overlayClip._visible = visibleValue;
};
_root.createEmptyMovieClip("myLine", 0);
hitArea_mc.onMouseDown = function () {
if (cover_mc._visible || (prompt_mc._visible)) {
return(undefined);
}
if (_root._ymouse > 410) {
return(undefined);
}
if (_root.buttons_mc.hitTest(_xmouse, _ymouse, true)) {
return(undefined);
}
trace("onMouseDown:: hit - start draw operation");
drawnAnything = true;
if (undoState) {
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 1).duplicateMovieClip("overlay" + textures[activeTexture].depthCounter, textures[activeTexture].depthCounter);
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 1)._visible = false;
} else {
textures[activeTexture].depthCounter++;
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 1).duplicateMovieClip("overlay" + textures[activeTexture].depthCounter, textures[activeTexture].depthCounter);
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 1)._visible = false;
}
undoState = false;
textures[activeTexture].getOverlayClip(textures[activeTexture].depthCounter - 2).removeMovieClip();
textures[activeTexture].getOverlayClip().moveTo(_xmouse, _ymouse);
textures[activeTexture].getOverlayClip().lineStyle(6, crayons[gCurrentColor].hexColor, 100);
_root.onMouseMove = function () {
textures[activeTexture].getOverlayClip().lineTo(_xmouse, _ymouse);
trace(("textures[activeTexture].getOverlayClip()" + textures[activeTexture].getOverlayClip()) + textures[activeTexture].getOverlayClip()._visible);
};
};
_root.onMouseUp = function () {
_root.onMouseMove = noLine;
};
texture.prototype.setActive = function (activeValue) {
if (activeValue) {
trace("activate called: " + this.maskClip._name);
deactivateAllTexturesBut(this.mID);
this.setVisible(true);
activeTexture = this.mID;
} else {
delete this.maskClip.onMouseMove;
this.setVisible(false);
}
};
hitArea_mc.onPress = function () {
painting = true;
};
hitArea_mc.onReleaseOutside = function () {
painting = false;
};
hitArea_mc.onRelease = function () {
trace("buttonReleased");
painting = false;
};
initialize();
var colorPages = new Array();
var currentColorPage = 0;
var currentAdjustedCrayon = 0;
colorPage.prototype.setActive = function () {
this.textureObj.setActive(true);
};
colorPage.prototype.clear = function () {
this.textureObj.clear();
this.textureObj.setActive(true);
};
setBook();
lines_mc.stop();
stop();
Symbol 39 Button
on (release) {
_parent.clearCurrentPage();
}
Symbol 43 Button
on (release) {
_parent.navButtonPressed(true);
}
Symbol 44 Button
on (release) {
_parent.navButtonPressed(false);
}
Symbol 48 Button
on (release) {
_parent.printButtonPressed(false);
}
Symbol 53 Button
on (release) {
crayonChosen(0);
}
Symbol 56 Button
on (release) {
crayonChosen(2);
}
Symbol 59 Button
on (release) {
crayonChosen(4);
}
Symbol 62 Button
on (release) {
crayonChosen(1);
}
Symbol 65 Button
on (release) {
crayonChosen(3);
}
Symbol 68 Button
on (release) {
crayonChosen(5);
}
Symbol 71 Button
on (release) {
crayonChosen(6);
}
Symbol 74 Button
on (release) {
crayonChosen(7);
}
Symbol 82 Button
on (release) {
undo();
}
Symbol 91 Button
on (release) {
_parent.coverPressed();
}
Symbol 95 Button
on (release) {
_parent._parent.printButtonPressed(true);
}
Symbol 96 Button
on (release) {
_parent._parent.coverPressed();
}
Symbol 106 Button
on (release) {
_parent.promptChoice(false);
}
Symbol 109 Button
on (release) {
_parent.promptChoice(true);
}