STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229595
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2595 · P5190

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/52048352?noj=FRM52048352-22DC" width="1" height="1"></div>

direction.swf

This is the info page for
Flash #239035

(Click the ID number above for more basic data on this flash file.)


ActionScript [AS3]
Section 1
//Games (General.Games) package General { public class Games { private var gameOptions:Array; private var members:Array; private var gameName:String;// = "" private var options:Object; public function Games(members:Array){ options = new Object(); gameOptions = new Array(); super(); this.members = members; } public function add(gameName:String, options:Array):void{ if (this.gameName.length == 0){ this.gameName = gameName; }; this.options[gameName] = new Object(); var i:int; while (i < options.length) { this.options[gameName][members[i]] = options[i]; i++; }; } public function getGameList(gameName:String):String{ var item:String; var s:String = ""; var i:int; for (item in options) { s = (s + (gameName + ",")); s = (s + (i + ",")); s = (s + (item + ",")); s = (s + (options[item]["title"][0] + "\n")); i++; }; return (s); } public function getGame():String{ return (this.gameName); } public function game(gameName:String, valName:String){ return (options[gameName][valName]); } public function setGame(gameName:String):void{ if (options[gameName] == undefined){ } else { this.gameName = gameName; }; } public function option(valName:String){ return (options[gameName][valName]); } } }//package General
Section 2
//HighScores (General.HighScores) package General { import flash.net.*; public class HighScores { private var sttTime:Date; private var score:Number; public var gameMode:String; private var gameName:String; public function HighScores(gameName:String, gameMode:String){ sttTime = new Date(); super(); this.gameName = gameName; this.gameMode = gameMode; trace(("HighScores gameMode=" + gameMode)); } private function rotStr(to_enc:String, rot_key:String):String{ var the_res:String = ""; var i:int; while (i < 4) { the_res = (the_res + rotChr(to_enc.substr(i, 1), rot_key.substr(i, 1))); i++; }; return (the_res); } private function encodeBase64(input:String):String{ var chr1:Number; var chr2:Number; var chr3:Number; var enc1:Number; var enc2:Number; var enc3:Number; var enc4:Number; var output:String = ""; var keyStr:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_:"; var i:int; while (i < input.length) { var _temp1 = i; i = (i + 1); chr1 = input.charCodeAt(_temp1); var _temp2 = i; i = (i + 1); chr2 = input.charCodeAt(_temp2); var _temp3 = i; i = (i + 1); chr3 = input.charCodeAt(_temp3); enc1 = (chr1 >> 2); enc2 = (((chr1 & 3) << 4) | (chr2 >> 4)); enc3 = (((chr2 & 15) << 2) | (chr3 >> 6)); enc4 = (chr3 & 63); if (isNaN(chr2)){ enc4 = 64; enc3 = enc4; } else { if (isNaN(chr3)){ enc4 = 64; }; }; output = ((((output + keyStr.charAt(enc1)) + keyStr.charAt(enc2)) + keyStr.charAt(enc3)) + keyStr.charAt(enc4)); }; return (output); } private function cleanURL(s:String):String{ s = s.replace(" ", "%20"); return (s); } private function keyShuffle(a:String, b:String):String{ var places:int; var newpos:int; var temp:String; var alen:int = a.length; var aArr:Array = new Array(); var i:int; while (i < 4) { aArr[i] = a.substr(i, 1); i++; }; var blen:int = b.length; i = 0; while (i < 4) { places = ordOffset(b.substr(i, 1)); newpos = ((i + places) % 4); if (newpos != i){ temp = aArr[i]; aArr[i] = aArr[newpos]; aArr[newpos] = temp; }; i++; }; var c:String = ""; i = 0; while (i < 4) { c = (c + aArr[i]); i++; }; return (c); } private function pad0(n:Number):String{ if (n < 10){ return (("0" + n.toString())); }; return (n.toString()); } private function makeScoreStr(sttTime:Date, totElapsed:Number, gameName:String, gameMode:String, score:Number, totalCount:int, rightCount:int):String{ var v:String = "00"; var sep:String = "~"; var s:String = ""; s = (s + fmtTime(sttTime)); s = (s + sep); s = (s + int((sttTime.getTimezoneOffset() / 60))); s = (s + sep); s = (s + (totElapsed / 1000)); s = (s + sep); s = (s + gameName); s = (s + sep); s = (s + gameMode); s = (s + sep); s = (s + score.toString()); s = (s + sep); s = (s + totalCount); s = (s + sep); s = (s + rightCount); s = (s + sep); s = (s + keyMake(gameMode, score.toString())); s = encodeBase64(s); s = (v + s); return (s); } public function setStt():void{ sttTime = new Date(); } private function keyMake(a:String, b:String):String{ var both:String = (a + b); var c:String = both.substr(0, 4); var i = 1; while (i <= int((both.length / 4))) { c = rotStr(c, both.substr((i * 4), 4)); i++; }; c = keyShuffle(c, b); c = rotStr(c, b); return (c); } private function rotChr(chr1:String, chr2:String):String{ var ord1:int = ordOffset(chr1); var ord2:int = ordOffset(chr2); var rotnum:int = (ord1 + ord2); if (rotnum >= 26){ rotnum = (rotnum - 26); }; return (String.fromCharCode((rotnum + "a".charCodeAt(0)))); } public function addMe(newScore:Number, totalCount:int, rightCount:int):void{ score = fmt2(newScore); trace(score); var endTime:Date = new Date(); var elapsed:Number = (endTime.valueOf() - sttTime.valueOf()); trace(elapsed); var s:String = makeScoreStr(sttTime, elapsed, gameName, gameMode, score, totalCount, rightCount); var outgoing_lc:LocalConnection = new LocalConnection(); outgoing_lc.client = this; outgoing_lc.send("mathopolis", "methodToExecute", s); } private function ordOffset(chr1:String):int{ if (chr1.length == 0){ return (0); }; var ord1:int = chr1.toLowerCase().charCodeAt(0); if ((((ord1 >= 48)) && ((ord1 <= 57)))){ ord1 = (ord1 - 48); }; if ((((ord1 >= 97)) && ((ord1 <= 122)))){ ord1 = (ord1 - 97); }; if (ord1 > 26){ ord1 = 0; }; return (ord1); } private function fmtTime(t:Date):String{ var s:String = ""; s = (s + t.getFullYear().toString().substr(2, 2)); s = (s + pad0((t.getMonth() + 1))); s = (s + pad0(t.getDate())); s = (s + pad0(t.getHours())); s = (s + pad0(t.getMinutes())); s = (s + pad0(t.getSeconds())); return (s); } private function fmt2(x:Number):Number{ var x2:Number = (Math.round((x * 100)) / 100); return (x2); } } }//package General
Section 3
//CircleButton (GUI.CircleButton) package GUI { import flash.events.*; import flash.display.*; import flash.geom.*; public class CircleButton extends GoodSprite { private var symbolHi:Sprite; private var radius:int; private var innerCircle:Shape; private var downCircle2:Shape; private var outerCircle:Shape; private var tb:TextBox; private var downCircle:Shape; private var symbolLo:Sprite; public function CircleButton(radius:int=23):void{ symbolLo = new Sprite(); symbolHi = new Sprite(); super(); this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); this.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); this.buttonMode = true; this.useHandCursor = true; this.radius = radius; outerCircle = createGradient(radius, (-(Math.PI) / 6)); this.addChild(outerCircle); innerCircle = createGradient((radius * 0.85), ((-(Math.PI) / 6) - Math.PI)); this.addChild(innerCircle); downCircle = createGradient(radius, ((-(Math.PI) / 6) - Math.PI)); downCircle.visible = false; this.addChild(downCircle); downCircle2 = createGradient((radius * 0.85), (-(Math.PI) / 6)); downCircle2.visible = false; this.addChild(downCircle2); this.addChild(symbolLo); this.addChild(symbolHi); symbolLo.visible = true; symbolHi.visible = false; tb = new TextBox("Arial", (radius / 2), (radius * 2), 1, "OK", -(radius), (-(radius) / 3)); tb.setFontClr(0xFFFFFF); tb.setAlign("center"); tb.mouseEnabled = false; this.addChild(tb); } private function createGradient(radius:Number, angle:Number):Shape{ var gradient:Shape = new Shape(); var matrix:Matrix = new Matrix(); matrix.createGradientBox((radius * 2), (radius * 2), angle, -(radius), -(radius)); gradient.graphics.beginGradientFill("linear", [153, 0xFFFFFF], [100, 100], [0, 0xFF], matrix, "pad", "RGB", 0); gradient.graphics.moveTo(0, 0); gradient.graphics.drawCircle(0, 0, radius); gradient.graphics.endFill(); return (gradient); } private function onMouseOut(ev:MouseEvent):void{ outerCircle.alpha = 1; innerCircle.alpha = 1; downCircle.visible = false; downCircle2.visible = false; symbolLo.visible = true; symbolHi.visible = false; } private function onMouseOver(ev:MouseEvent):void{ outerCircle.alpha = 0.4; symbolLo.visible = false; symbolHi.visible = true; } private function onMouseUp(ev:MouseEvent):void{ downCircle.visible = false; downCircle2.visible = false; symbolLo.visible = true; symbolHi.visible = false; } public function setStyle(style:String):void{ this.tb.visible = false; symbolLo.graphics.clear(); symbolHi.graphics.clear(); switch (style){ case "play": symbolLo.graphics.lineStyle(3, 0xFFFFFF, 1); symbolLo.graphics.moveTo((-(radius) * 0.4), (-(radius) * 0.5)); symbolLo.graphics.lineTo((-(radius) * 0.4), (radius * 0.5)); symbolLo.graphics.lineTo((radius * 0.5), 0); symbolLo.graphics.lineTo((-(radius) * 0.4), (-(radius) * 0.5)); symbolHi.graphics.beginFill(0xFF00FF); symbolHi.graphics.lineStyle(3, 0xFFFFFF, 1); symbolHi.graphics.moveTo((-(radius) * 0.4), (-(radius) * 0.5)); symbolHi.graphics.lineTo((-(radius) * 0.4), (radius * 0.5)); symbolHi.graphics.lineTo((radius * 0.5), 0); symbolHi.graphics.lineTo((-(radius) * 0.4), (-(radius) * 0.5)); symbolHi.graphics.endFill(); break; }; } private function onMouseDown(ev:MouseEvent):void{ downCircle.alpha = 0.3; downCircle.visible = true; downCircle2.visible = true; symbolLo.visible = false; symbolHi.visible = true; } public function setText(s:String):void{ tb.text = s; } } }//package GUI
Section 4
//CircleTimer (GUI.CircleTimer) package GUI { import flash.events.*; import flash.display.*; import flash.utils.*; public class CircleTimer extends Sprite { private var timeShape:Shape; private var timeStt:int; public var timingQ:Boolean;// = false private var Seconds:int;// = 0 public function CircleTimer(){ timeShape = new Shape(); super(); var bg:Shape = new Shape(); bg.graphics.lineStyle(5, 14540287, 1); bg.graphics.beginFill(15658751); bg.graphics.moveTo(0, 0); bg.graphics.drawCircle(0, 0, 35); bg.graphics.endFill(); addChild(bg); addChild(timeShape); } private function timeLoop(ev:Event):void{ var Pct:Number; var degrees:Number; timeShape.graphics.clear(); var Elapsed:Number = ((getTimer() - timeStt) / 1000); if (Elapsed < Seconds){ Pct = (Elapsed / Seconds); degrees = Math.min(360, (360 * Pct)); HiGraphics.drawSector(timeShape, 0, 0, 30, (0 - 90), (degrees - 90), 0, 1, 0xFF, true); } else { trace("time ends"); timeShape.graphics.beginFill(0x880088); timeShape.graphics.drawCircle(0, 0, 30); timeShape.graphics.endFill(); removeEventListener(Event.ENTER_FRAME, timeLoop); dispatchEvent(new Event("TimesUp")); }; } public function start(TheSeconds:int, TheClr:uint):void{ Seconds = TheSeconds; var Clr:uint = TheClr; timingQ = true; timeStt = getTimer(); addEventListener(Event.ENTER_FRAME, timeLoop); } } }//package GUI
Section 5
//Colors (GUI.Colors) package GUI { public class Colors { private var clrs:Array; private var pts:Array; private var clrNum:Number;// = 0 public function Colors(){ clrs = [["Red", 0xFF0000], ["Violet", 15631086], ["Orange", 0xFFA500], ["LightSalmon", 16752762], ["SlateBlue", 6970061], ["Yellow", 0xFFFF00], ["Aquamarine", 8388564], ["Pink", 16761035], ["Coral", 16744272], ["Green", 0x8000], ["Black", 0], ["Lime", 0xFF00], ["PaleGreen", 10025880], ["SpringGreen", 65407], ["Teal", 0x8080], ["DarkSeaGreen", 9419919], ["HotPink", 16738740], ["Yellow", 0xFFFF00], ["Blue", 0xFF], ["Aqua", 0xFFFF], ["Gold", 0xFFD700], ["Khaki", 15787660], ["Thistle", 14204888], ["Cyan", 0xFFFF], ["LightBlue", 11393254], ["SkyBlue", 8900331], ["Navy", 128], ["Purple", 0x800080], ["Wheat", 16113331], ["Tan", 13808780], ["AntiqueWhite", 16444375], ["Silver", 0xC0C0C0]]; pts = new Array(); super(); } public function RGB2Clr(Red:int, Green:int, Blue:int):uint{ return ((((Red << 16) | (Green << 8)) | Blue)); } public function createRandomGrid(width:int, height:int, ptCount:int):void{ var ptX:Number; var ptY:Number; var ptClr:uint; pts = []; var i:int; while (i < ptCount) { ptX = (Math.random() * width); ptY = (Math.random() * height); ptClr = clrs[Maths.randomRange(0, clrs.length)][1]; pts.push([ptX, ptY, ptClr]); i++; }; } public function getClrAt(width:int, height:int):uint{ var dist:Number; var fact:Number; var rgb:Array; var sumClrs:Array = new Array(); var sumClr:Number = 0; var sumFact:Number = 0; sumClrs = [0, 0, 0]; var i:int; while (i < pts.length) { dist = Maths.dist((pts[i][0] - width), (pts[i][1] - height)); fact = (1 / dist); rgb = Clr2RGB(pts[i][2]); sumClrs[0] = (sumClrs[0] + (rgb[0] * fact)); sumClrs[1] = (sumClrs[1] + (rgb[1] * fact)); sumClrs[2] = (sumClrs[2] + (rgb[2] * fact)); sumFact = (sumFact + fact); i++; }; var clr:uint = RGB2Clr((sumClrs[0] / sumFact), (sumClrs[1] / sumFact), (sumClrs[2] / sumFact)); return (clr); } public function getNext():Number{ clrNum++; if (clrNum >= clrs.length){ clrNum = 0; }; return (clrs[clrNum][1]); } public function Clr2RGB(clr:uint):Array{ var clrs:Array = []; clrs.push(((clr >> 16) & 0xFF)); clrs.push(((clr >> 8) & 0xFF)); clrs.push((clr & 0xFF)); return (clrs); } public function getLightness():Number{ var clr:uint = clrs[clrNum][1]; var r:uint = (clr >> 16); var g:uint = ((clr >> 8) & 0xFF); var b:uint = (clr & 0xFF); return (((((r + g) + b) / 3) / 0xFF)); } } }//package GUI
Section 6
//GoodSprite (GUI.GoodSprite) package GUI { import flash.events.*; import flash.display.*; public class GoodSprite extends Sprite { private var shakeStep:Number;// = 0 private var alphaStep:Number;// = 0 private var shakes:Array; public function GoodSprite(){ shakes = new Array(); super(); } private function fadeLoop(ev:Event):void{ if (alphaStep < 0){ if (this.alpha > 0){ this.alpha = (this.alpha + alphaStep); } else { this.alpha = 0; this.visible = false; removeEventListener(Event.ENTER_FRAME, fadeLoop); }; } else { if (this.alpha < 1){ this.alpha = (this.alpha + alphaStep); } else { this.alpha = 1; removeEventListener(Event.ENTER_FRAME, fadeLoop); }; }; } public function shake():void{ var factor:Number = (3 * Maths.randomRange(1, 2)); this.shakes.push(factor); this.shakes.push((factor * 2)); var i:int; while (i < (factor * 2)) { this.shakes.push(((factor * 2) - i)); i = (i + 2); }; shakeStep = 0; addEventListener(Event.ENTER_FRAME, shakeLoop); } private function shakeLoop(ev:Event):void{ if (shakeStep < shakes.length){ if ((shakeStep % 2) == 0){ this.x = (this.x - this.shakes[shakeStep]); } else { this.x = (this.x + this.shakes[shakeStep]); }; shakeStep++; } else { removeEventListener(Event.ENTER_FRAME, shakeLoop); }; } public function fade(alphaStep:Number):void{ this.alphaStep = alphaStep; this.visible = true; if (alphaStep < 0){ this.alpha = 1; } else { this.alpha = 0; }; addEventListener(Event.ENTER_FRAME, fadeLoop); } } }//package GUI
Section 7
//Popup (GUI.Popup) package GUI { import flash.events.*; import flash.display.*; import flash.geom.*; public class Popup extends Sprite { public var OKBtn:CircleButton; private var appearType:String;// = "pop" public function Popup(){ super(); trace("new Popup"); var BG:Shape = createGradient(300, (-(Math.PI) * 0.6)); addChild(BG); var FG:Shape = new Shape(); FG.graphics.beginFill(8947967, 1); FG.graphics.drawRoundRect(0, 0, 300, 100, 30); FG.graphics.endFill(); addChild(FG); OKBtn = new CircleButton(); OKBtn.x = 270; OKBtn.y = 70; addChild(OKBtn); OKBtn.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); } public function setAppearType(appearType:String):void{ appearType = this.appearType; } public function close():void{ trace("close"); switch (appearType){ case "pop": parent.removeChild(this); break; case "slide": break; }; } private function onMouseDown(ev:MouseEvent):void{ trace("onMouseDown"); this.close(); } public function open():void{ switch (appearType){ case "pop": parent.addChild(this); break; case "slide": break; }; } private function createGradient(size:Number, angle:Number):Shape{ var gradient:Shape = new Shape(); var matrix:Matrix = new Matrix(); matrix.createGradientBox(size, size, angle, 0, 0); gradient.graphics.beginGradientFill("linear", [0, 14540287], [100, 100], [0, 0xFF], matrix, "pad", "RGB", 0); var edge = 5; gradient.graphics.moveTo(0, 0); gradient.graphics.drawRoundRect(-(edge), -(edge), (size + (edge * 2)), (100 + (edge * 2)), (30 + edge)); gradient.graphics.endFill(); return (gradient); } } }//package GUI
Section 8
//ScoreBoard (GUI.ScoreBoard) package GUI { import flash.display.*; import flash.geom.*; public class ScoreBoard extends Sprite { private var midClr:Number;// = 13421823 private var bg:Sprite; private var high:int;// = 90 private var brdrClr:Number;// = 13421823 private var scoreLbl:TextBox; private var wide:int;// = 600 private var score:int;// = 0 private var scoreBox:Sprite; private var bgShape:Shape; private var scoreText:TextBox; public function ScoreBoard(){ bg = new Sprite(); bgShape = new Shape(); scoreBox = new Sprite(); scoreLbl = new TextBox("Arial", 16, 80, 1, "Score", 0, 0); scoreText = new TextBox("Arial", 20, 80, 1, "0", 0, 22); super(); bgShape = createGradient((high * 1.2), (Math.PI / 2), brdrClr, midClr); bg.addChild(bgShape); addChild(bg); scoreLbl.setAlign("center"); scoreBox.addChild(scoreLbl); scoreBox.graphics.beginFill(16777164, 1); scoreBox.graphics.lineStyle(1, 0x888888, 1); scoreBox.graphics.drawRect(0, 20, 80, 30); scoreBox.graphics.endFill(); scoreText.setAlign("center"); scoreBox.addChild(scoreText); scoreBox.x = 400; scoreBox.y = 20; addChild(scoreBox); } public function addScore(x:int):void{ score = (score + x); if (score < 0){ score = 0; }; scoreText.setText(score.toString()); } public function getScore():int{ return (score); } private function createGradient(radius:Number, angle:Number, borderClr:Number, hiliteClr:Number):Shape{ var gradient:Shape = new Shape(); var matrix:Matrix = new Matrix(); matrix.createGradientBox(radius, radius, angle, 0, 0); gradient.graphics.beginGradientFill("linear", [0xFFFFFF, hiliteClr, 0xFFFFFF], [100, 100, 100], [0, 136, 0xFF], matrix, "pad", "RGB", 0); gradient.graphics.lineStyle(2, borderClr, 1); gradient.graphics.moveTo(0, 0); gradient.graphics.drawRoundRect(0, 0, wide, high, high, high); gradient.graphics.endFill(); return (gradient); } public function setScore(x:int):void{ score = x; scoreText.setText(score.toString()); } } }//package GUI
Section 9
//TextBox (GUI.TextBox) package GUI { import flash.display.*; import flash.text.*; public class TextBox extends TextField { private var tf:TextFormat; public function TextBox(fontName:String, fontSize:Number, width:Number, lines:Number=1, textNew:String="", xNew:int=0, yNew:int=0):void{ tf = new TextFormat(); super(); this.x = 0; this.y = 0; this.width = width; this.height = (((lines * fontSize) * 1.1) + 6); this.border = false; this.multiline = true; this.wordWrap = true; this.selectable = false; this.mouseEnabled = false; this.blendMode = BlendMode.LAYER; this.text = textNew; this.x = xNew; this.y = yNew; tf.size = fontSize; tf.color = 0; tf.font = fontName; tf.bold = true; this.setTextFormat(tf); this.defaultTextFormat = tf; } public function setFontClr(fontClr:Number):void{ tf.color = fontClr; this.defaultTextFormat = tf; this.setTextFormat(tf); } public function setAlign(align:String):void{ tf.align = align; this.defaultTextFormat = tf; this.setTextFormat(tf); } public function cleanup():void{ parent.removeChild(this); } public function setText(s:String):void{ this.text = s; } } }//package GUI
Section 10
//Ticks (GUI.Ticks) package GUI { import flash.display.*; public class Ticks extends Sprite { private var maxTicks:int;// = 5 private var ticks:Array; private var TickImg:Class; public function Ticks(){ var tick:Bitmap; TickImg = Ticks_TickImg; ticks = new Array(); super(); var i:int; while (i < maxTicks) { tick = new TickImg(); tick.x = (i * 38); tick.y = 0; ticks[i] = tick; trace(("x=" + tick.x)); i++; }; i = (maxTicks - 1); while (i >= 0) { addChild(ticks[i]); i--; }; } public function showTicks(count:int):void{ var i:int; while (i < maxTicks) { if (i < count){ ticks[i].alpha = 1; } else { ticks[i].alpha = 0.1; }; i++; }; } public function hideTicks():void{ var i:int; while (i < maxTicks) { ticks[i].alpha = 0; i++; }; } } }//package GUI
Section 11
//Ticks_TickImg (GUI.Ticks_TickImg) package GUI { import mx.core.*; public class Ticks_TickImg extends BitmapAsset { } }//package GUI
Section 12
//Tile (GUI.Tile) package GUI { import flash.events.*; import flash.display.*; public class Tile extends Sprite { private var size:int;// = 40 public var loClr:uint;// = 16777164 public var hiClr:uint;// = 0xFF public var tileNum:int;// = 0 public function Tile(size:int){ super(); this.size = size; this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); drawMe(0xCCCCCC, loClr); } public function onMouseDown(ev:MouseEvent):void{ dispatchEvent(new Event("TileClick")); } public function onMouseOut(ev:MouseEvent):void{ drawMe(0xCCCCCC, loClr); } public function setBGClr(clr:uint):void{ loClr = clr; drawMe(0xCCCCCC, loClr); } public function onMouseOver(ev:MouseEvent):void{ drawMe(0xCCCCCC, hiClr); } private function drawMe(edgeClr:uint, bgClr:uint):void{ var edgeClr = edgeClr; var bgClr = bgClr; var _local4 = this.graphics; with (_local4) { clear(); lineStyle(2, edgeClr); beginFill(bgClr, 35); moveTo(0, 0); lineTo(size, 0); lineTo(size, size); lineTo(0, size); lineTo(0, 0); endFill(); }; } } }//package GUI
Section 13
//BitmapAsset (mx.core.BitmapAsset) package mx.core { import flash.display.*; public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject { mx_internal static const VERSION:String = "3.3.0.4852"; public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){ super(bitmapData, pixelSnapping, smoothing); } public function get measuredWidth():Number{ if (bitmapData){ return (bitmapData.width); }; return (0); } public function get measuredHeight():Number{ if (bitmapData){ return (bitmapData.height); }; return (0); } public function setActualSize(newWidth:Number, newHeight:Number):void{ width = newWidth; height = newHeight; } public function move(x:Number, y:Number):void{ this.x = x; this.y = y; } } }//package mx.core
Section 14
//FlexBitmap (mx.core.FlexBitmap) package mx.core { import flash.display.*; import mx.utils.*; public class FlexBitmap extends Bitmap { mx_internal static const VERSION:String = "3.3.0.4852"; public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){ var bitmapData = bitmapData; var pixelSnapping = pixelSnapping; var smoothing = smoothing; super(bitmapData, pixelSnapping, smoothing); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 15
//IFlexAsset (mx.core.IFlexAsset) package mx.core { public interface IFlexAsset { } }//package mx.core
Section 16
//IFlexDisplayObject (mx.core.IFlexDisplayObject) package mx.core { import flash.events.*; import flash.display.*; import flash.geom.*; import flash.accessibility.*; public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher { function get visible():Boolean; function get rotation():Number; function localToGlobal(void:Point):Point; function get name():String; function set width(flash.display:Number):void; function get measuredHeight():Number; function get blendMode():String; function get scale9Grid():Rectangle; function set name(flash.display:String):void; function set scaleX(flash.display:Number):void; function set scaleY(flash.display:Number):void; function get measuredWidth():Number; function get accessibilityProperties():AccessibilityProperties; function set scrollRect(flash.display:Rectangle):void; function get cacheAsBitmap():Boolean; function globalToLocal(void:Point):Point; function get height():Number; function set blendMode(flash.display:String):void; function get parent():DisplayObjectContainer; function getBounds(String:DisplayObject):Rectangle; function get opaqueBackground():Object; function set scale9Grid(flash.display:Rectangle):void; function setActualSize(_arg1:Number, _arg2:Number):void; function set alpha(flash.display:Number):void; function set accessibilityProperties(flash.display:AccessibilityProperties):void; function get width():Number; function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean; function set cacheAsBitmap(flash.display:Boolean):void; function get scaleX():Number; function get scaleY():Number; function get scrollRect():Rectangle; function get mouseX():Number; function get mouseY():Number; function set height(flash.display:Number):void; function set mask(flash.display:DisplayObject):void; function getRect(String:DisplayObject):Rectangle; function get alpha():Number; function set transform(flash.display:Transform):void; function move(_arg1:Number, _arg2:Number):void; function get loaderInfo():LoaderInfo; function get root():DisplayObject; function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean; function set opaqueBackground(flash.display:Object):void; function set visible(flash.display:Boolean):void; function get mask():DisplayObject; function set x(flash.display:Number):void; function set y(flash.display:Number):void; function get transform():Transform; function set filters(flash.display:Array):void; function get x():Number; function get y():Number; function get filters():Array; function set rotation(flash.display:Number):void; function get stage():Stage; } }//package mx.core
Section 17
//IRepeaterClient (mx.core.IRepeaterClient) package mx.core { public interface IRepeaterClient { function get instanceIndices():Array; function set instanceIndices(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function get isDocument():Boolean; function set repeaters(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function initializeRepeaterArrays(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void; function get repeaters():Array; function set repeaterIndices(C:\autobuild\3.3.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function get repeaterIndices():Array; } }//package mx.core
Section 18
//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 19
//NameUtil (mx.utils.NameUtil) package mx.utils { import flash.display.*; import mx.core.*; import flash.utils.*; public class NameUtil { mx_internal static const VERSION:String = "3.3.0.4852"; private static var counter:int = 0; public function NameUtil(){ super(); } public static function displayObjectToString(displayObject:DisplayObject):String{ var result:String; var o:DisplayObject; var s:String; var indices:Array; var displayObject = displayObject; o = displayObject; while (o != null) { if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){ break; }; s = o.name; if ((o is IRepeaterClient)){ indices = IRepeaterClient(o).instanceIndices; if (indices){ s = (s + (("[" + indices.join("][")) + "]")); }; }; result = ((result == null)) ? s : ((s + ".") + result); o = o.parent; }; //unresolved jump var _slot1 = e; return (result); } public static function createUniqueName(object:Object):String{ if (!object){ return (null); }; var name:String = getQualifiedClassName(object); var index:int = name.indexOf("::"); if (index != -1){ name = name.substr((index + 2)); }; var charCode:int = name.charCodeAt((name.length - 1)); if ((((charCode >= 48)) && ((charCode <= 57)))){ name = (name + "_"); }; return ((name + counter++)); } } }//package mx.utils
Section 20
//HiGraphics (HiGraphics) package { import flash.display.*; public class HiGraphics { public function HiGraphics(){ super(); } public static function drawSector(destShape:Shape, midX:int, midY:int, size:int, FromDeg:Number, ToDeg:Number, lineCol:uint, lineAlpha:Number=1, fillCol:uint=0, fillQ:Boolean=false):void{ var steps:*; var i:*; var radians:*; var thisX:*; var thisY:*; var destShape = destShape; var midX = midX; var midY = midY; var size = size; var FromDeg = FromDeg; var ToDeg = ToDeg; var lineCol = lineCol; var lineAlpha = lineAlpha; var fillCol = fillCol; var fillQ = fillQ; var _local12 = destShape.graphics; with (_local12) { if (fillQ){ beginFill(fillCol, 1); }; lineStyle(1, lineCol, lineAlpha); steps = Math.max(1, int(((ToDeg - FromDeg) / 5))); moveTo(midX, midY); i = 0; while (i <= steps) { radians = ((FromDeg + ((ToDeg - FromDeg) * (i / steps))) / 57.296); thisX = (midX + (Math.cos(radians) * size)); thisY = (midY + (Math.sin(radians) * size)); lineTo(thisX, thisY); i++; }; lineTo(midX, midY); if (fillQ){ endFill(); }; }; } public static function drawPipe(destShape:Shape, x0:Number, y0:Number, x1:Number, y1:Number, clr:uint):void{ var j:*; var dist:*; var destShape = destShape; var x0 = x0; var y0 = y0; var x1 = x1; var y1 = y1; var clr = clr; var alpha:Array = [1, 0.8, 0.6, 0.4, 0.4, 0.2, 0.4, 0.6, 1]; var size:int = alpha.length; var i:int; while (i < size) { var _local8 = destShape.graphics; with (_local8) { j = 0; while (j < 2) { if (j == 0){ lineStyle(1, 0xFFFFFF, 1); } else { lineStyle(1, clr, alpha[i]); }; dist = (((size / 2) - (1 / 2)) - i); if (y0 == y1){ moveTo(x0, (y0 - dist)); lineTo(x1, (y1 - dist)); }; if (x0 == x1){ moveTo((x0 + dist), y0); lineTo((x1 + dist), y1); }; j++; }; }; i = (i + 1); }; } public static function drawArrow(destShape:Shape, x0:Number, y0:Number, arrowlen:Number, arrowht:Number, clr:uint):void{ var destShape = destShape; var x0 = x0; var y0 = y0; var arrowlen = arrowlen; var arrowht = arrowht; var clr = clr; var _local8 = destShape.graphics; with (_local8) { beginFill(clr, 100); moveTo(x0, y0); lineTo((x0 - arrowlen), (y0 + (arrowht / 2))); lineTo((x0 - arrowlen), (y0 - (arrowht / 2))); lineTo(x0, y0); endFill(); }; } public static function drawPipeCorner(destShape:Shape, x0:Number, y0:Number, fromUDLR:String, toUDLR:String, clr:uint):void{ var j:*; var dist:*; var destShape = destShape; var x0 = x0; var y0 = y0; var fromUDLR = fromUDLR; var toUDLR = toUDLR; var clr = clr; var alpha:Array = [1, 0.8, 0.6, 0.4, 0.4, 0.2, 0.4, 0.6, 1]; var size:int = alpha.length; var radius:int = ((size / 2) - (1 / 2)); var i:int; while (i < size) { var _local8 = destShape.graphics; with (_local8) { j = 0; while (j < 2) { if (j == 0){ lineStyle(1, 0xFFFFFF, 1); } else { lineStyle(1, clr, alpha[i]); }; dist = (((size / 2) - (1 / 2)) - i); switch (((fromUDLR + ",") + toUDLR)){ case "3,1": case "0,2": moveTo((x0 - radius), ((y0 - radius) + i)); lineTo((((x0 + radius) - i) + 1), ((y0 - radius) + i)); moveTo(((x0 + radius) - i), ((y0 - radius) + i)); lineTo(((x0 + radius) - i), ((y0 + radius) + 1)); break; case "3,0": case "1,2": moveTo((x0 - radius), ((y0 - radius) + i)); lineTo((((x0 - radius) + i) + 1), ((y0 - radius) + i)); moveTo(((x0 + radius) - i), (y0 - radius)); lineTo(((x0 + radius) - i), ((y0 + radius) - i)); break; case "2,1": case "0,3": moveTo((x0 + radius), ((y0 - radius) + i)); lineTo(((x0 - radius) + i), ((y0 - radius) + i)); moveTo(((x0 + radius) - i), ((y0 + radius) - i)); lineTo(((x0 + radius) - i), (y0 + radius)); break; case "2,0": case "1,3": moveTo((x0 + radius), ((y0 - radius) + i)); lineTo(((x0 + radius) - i), ((y0 - radius) + i)); moveTo(((x0 + radius) - i), (y0 - radius)); lineTo(((x0 + radius) - i), ((y0 - radius) + i)); break; }; j++; }; }; i = (i + 1); }; } } }//package
Section 21
//Main (Main) package { import flash.events.*; import flash.display.*; import flash.geom.*; import GUI.*; import General.*; import flash.utils.*; public class Main extends Sprite { private var tiles:Array; private var playerPosY:Number;// = 0 private var instructText:TextBox; private var playBtn:CircleButton; private var PlayerImg:Class; private var playerPosX:Number;// = 0 private var tileSprite:Sprite; private var playerImg:Bitmap; private var mapHeight:Number;// = 0 private var finalY:Number;// = 0 private var userPosition:Number;// = 0 private var finalX:Number;// = 0 private var startX:Number;// = 0 private var startY:Number;// = 0 private var tileWidth:Number;// = 30 private var finalPosition:Number;// = 0 private var games:Games; private var timer:CircleTimer; private var route:Array; private var mapWidth:Number;// = 0 private var compassImg:Bitmap; private var pathSprite:Shape; private var gameOverVar:Boolean;// = false private var highScores:HighScores; private var clrs:Colors; private var gamesPopup:Popup; private var CompassImg:Class; private var summaryText:TextBox; private var scoreBoard:ScoreBoard; private var tileHeight:Number;// = 30 private var ticks:Ticks; public function Main():void{ PlayerImg = Main_PlayerImg; playerImg = new PlayerImg(); CompassImg = Main_CompassImg; compassImg = new CompassImg(); ticks = new Ticks(); playBtn = new CircleButton(40); summaryText = new TextBox("Arial", 36, 560, 1, "", 40, 220); instructText = new TextBox("Arial", 20, 300, 10, "", 30, 30); timer = new CircleTimer(); scoreBoard = new ScoreBoard(); gamesPopup = new Popup(); clrs = new Colors(); tiles = new Array(); tileSprite = new Sprite(); pathSprite = new Shape(); route = new Array(); super(); if (stage){ init(); } else { addEventListener(Event.ADDED_TO_STAGE, init); }; } private function check():void{ trace("check"); trace(((("final:" + finalX) + ",") + finalY)); var userY:Number = int((userPosition / mapWidth)); var userX:Number = (userPosition - (userY * mapWidth)); trace(((("user:" + userX) + ",") + userY)); var decrease:int = int((Maths.dist((userX - finalX), (userY - finalY)) * 2.3)); trace(("decrease:" + decrease)); var currScore:Number = (5 - decrease); if (currScore < 0){ currScore = 0; }; var endP:Point = new Point(((startX + (finalX * tileWidth)) + (tileWidth / 2)), ((startY + (finalY * tileHeight)) + (tileHeight / 2))); pathSprite.graphics.moveTo(endP.x, endP.y); pathSprite.graphics.beginFill(0xFF0000, 1); pathSprite.graphics.drawCircle(endP.x, endP.y, 12); pathSprite.graphics.endFill(); ticks.showTicks(currScore); ticks.visible = true; scoreBoard.addScore(currScore); setTimeout(newRound, 1000); } private function init(e:Event=null):void{ removeEventListener(Event.ADDED_TO_STAGE, init); games = new Games(["title", "moves", "minWidth", "maxWidth", "minHeight", "maxHeight", "neg"]); games.add("2", [["2 Moves", ""], 2, 10, 15, 6, 10, false]); games.add("3", [["3 Moves", ""], 3, 10, 15, 6, 10, false]); games.add("4", [["4 Moves", ""], 4, 10, 15, 6, 10, false]); games.add("4neg", [["4 Moves incl negatives", ""], 4, 10, 15, 6, 10, true]); games.add("5", [["5 Moves", ""], 5, 10, 15, 6, 10, false]); games.add("5neg", [["5 Moves incl negatives", ""], 5, 10, 15, 6, 10, true]); games.setGame(this.root.loaderInfo.parameters["m"]); highScores = new HighScores("Direction", games.getGame()); gamesPopup.setAppearType("slide"); gamesPopup.visible = false; addChild(gamesPopup); playBtn.x = (stage.stageWidth / 2); playBtn.y = 160; playBtn.setStyle("play"); playBtn.addEventListener(MouseEvent.MOUSE_DOWN, newGame); addChild(playBtn); scoreBoard.x = 20; scoreBoard.y = 320; addChild(scoreBoard); timer.x = 70; timer.y = 365; addChild(timer); addChild(tileSprite); addChild(pathSprite); ticks.x = 210; ticks.y = 260; ticks.visible = false; addChild(ticks); playerImg.scaleX = 0.6; playerImg.scaleY = 0.6; addChild(playerImg); compassImg.x = 18; compassImg.y = 200; addChild(compassImg); addChild(instructText); summaryText.setAlign("center"); addChild(summaryText); clearAll(); } private function newGame(ev:MouseEvent):void{ highScores.setStt(); clearAll(); gameOverVar = false; playBtn.fade(-0.1); scoreBoard.setScore(0); timer.start(60, 0xFF); timer.addEventListener("TimesUp", gameOver); playerImg.visible = true; instructText.visible = true; summaryText.visible = false; newRound(); } private function tracePath():void{ var tempX:*; var tempY:*; var i:*; var p0:*; var p1:*; pathSprite.graphics.clear(); var _local2 = pathSprite.graphics; with (_local2) { tempX = playerPosX; tempY = playerPosY; lineStyle(2, 0xFF, 100); i = 0; while (i < route.length) { p0 = new Point(((startX + (tempX * tileWidth)) + (tileWidth / 2)), ((startY + (tempY * tileHeight)) + (tileHeight / 2))); switch (route[i][0]){ case 0: tempY = (tempY - route[i][1]); break; case 1: tempY = (tempY + route[i][1]); break; case 2: tempX = (tempX - route[i][1]); break; case 3: tempX = (tempX + route[i][1]); break; }; p1 = new Point(((startX + (tempX * tileWidth)) + (tileWidth / 2)), ((startY + (tempY * tileHeight)) + (tileHeight / 2))); HiGraphics.drawPipe(pathSprite, p0.x, p0.y, p1.x, p1.y, 0xFF); if (i > 0){ HiGraphics.drawPipeCorner(pathSprite, p0.x, p0.y, route[(i - 1)][0], route[i][0], 0xFF); }; i++; }; }; } private function clearTiles():void{ var i:int; while (i < tiles.length) { tileSprite.removeChild(tiles[i]); i++; }; tiles = []; } private function newRound():void{ if (!gameOverVar){ ticks.visible = false; userPosition = 0; instructText.setText(""); pathSprite.graphics.clear(); clearTiles(); generate(); }; } private function clearAll():void{ summaryText.setText(""); clearTiles(); playerImg.visible = false; instructText.visible = false; } private function onTileClick(ev:Event):void{ trace(("ggg=" + ev.currentTarget.tileNum)); userPosition = ev.currentTarget.tileNum; tracePath(); check(); } private function gameOver(ev:Event):void{ trace("game over"); gameOverVar = true; playBtn.fade(0.1); clearAll(); summaryText.setText(("Total Score: " + scoreBoard.getScore().toString())); summaryText.visible = true; highScores.addMe(scoreBoard.getScore(), 0, 0); } private function generate():void{ var i:int; var tile:Tile; var possible:*; var found:*; var direction:*; var stepCount:int; var negQ:Boolean; var dirType:String; mapWidth = Maths.randomRange(games.option("minWidth"), games.option("maxWidth")); mapHeight = Maths.randomRange(games.option("minHeight"), games.option("maxHeight")); playerPosX = Maths.randomRange(0, mapWidth); playerPosY = Maths.randomRange(0, mapHeight); var currentTile:Number = Maths.randomRange(1, 7); startX = (int(((stage.stageWidth / 2) - ((mapWidth * tileWidth) / 2))) + 80); startY = (int(((stage.stageHeight / 2) - ((mapHeight * tileHeight) / 2))) - 70); clrs.createRandomGrid(mapWidth, mapHeight, 3); i = 0; while (i < (mapWidth * mapHeight)) { tile = new Tile(30); tile.x = (startX + ((i % mapWidth) * tileWidth)); tile.y = (startY + (int((i / mapWidth)) * tileHeight)); tile.tileNum = i; tile.addEventListener("TileClick", onTileClick); tile.setBGClr(clrs.getClrAt((i % mapWidth), int((i / mapWidth)))); tileSprite.addChild(tile); tiles[i] = tile; i++; }; playerImg.x = (startX + (playerPosX * tileWidth)); playerImg.y = (startY + (playerPosY * tileHeight)); route = new Array(); var moveCount:Number = Maths.randomRange(2, 6); moveCount = games.option("moves"); var counter:Number = 0; var tempPosX:Number = playerPosX; var tempPosY:Number = playerPosY; var prevDirn = -1; do { route[counter] = new Array(); possible = new Array(0, 0, 0, 0); possible[0] = tempPosY; possible[1] = ((mapHeight - 1) - tempPosY); possible[2] = tempPosX; possible[3] = ((mapWidth - 1) - tempPosX); switch (prevDirn){ case 0: case 1: possible[0] = 0; possible[1] = 0; break; case 2: case 3: possible[2] = 0; possible[3] = 0; break; }; found = false; do { direction = Maths.randomRange(0, 5); if (possible[direction] > 0){ found = true; }; } while (!(found)); prevDirn = direction; route[counter][0] = direction; route[counter][1] = Maths.randomRange(1, (possible[direction] + 1)); switch (direction){ case 0: tempPosY = (tempPosY - route[counter][1]); break; case 1: tempPosY = (tempPosY + route[counter][1]); break; case 2: tempPosX = (tempPosX - route[counter][1]); break; case 3: tempPosX = (tempPosX + route[counter][1]); break; }; counter++; } while (counter < moveCount); trace(((tempPosX + ",") + tempPosY)); trace((tempPosX + (mapWidth * tempPosY))); finalPosition = (tempPosX + (mapWidth * tempPosY)); finalX = tempPosX; finalY = tempPosY; var dirns:Array = new Array(); dirns["n+"] = ["north", "south", "west", "east"]; dirns["n-"] = ["south", "north", "east", "west"]; var instruct:String = ""; i = 0; while (i < route.length) { stepCount = route[i][1]; negQ = false; if (((games.option("neg")) && ((Math.random() > 0.7)))){ negQ = true; }; if (negQ){ dirType = "n-"; stepCount = -(stepCount); } else { dirType = "n+"; }; instruct = (instruct + stepCount); if (route[i][1] > 1){ instruct = (instruct + " steps "); } else { instruct = (instruct + " step "); }; instruct = (instruct + dirns[dirType][route[i][0]]); instruct = (instruct + "<br />"); i++; }; instructText.htmlText = instruct; } } }//package
Section 22
//Main_CompassImg (Main_CompassImg) package { import mx.core.*; public class Main_CompassImg extends BitmapAsset { } }//package
Section 23
//Main_PlayerImg (Main_PlayerImg) package { import mx.core.*; public class Main_PlayerImg extends BitmapAsset { } }//package
Section 24
//Maths (Maths) package { public class Maths { public function Maths(){ super(); } public function sign(n:Number):int{ var i:int = ((n < 0)) ? -1 : 1; return (i); } public static function randomRange(minVal:int, maxVal:int):int{ return ((Math.floor((Math.random() * (maxVal - minVal))) + minVal)); } public static function fmt(num:Number, digits:int):String{ if (digits <= 0){ return (Math.round(num).toString()); }; var tenToPower:Number = Math.pow(10, digits); var cropped:String = String((Math.round((num * tenToPower)) / tenToPower)); if (cropped.indexOf(".") == -1){ cropped = (cropped + ".0"); }; var halves:Array = cropped.split("."); var zerosNeeded:int = (digits - halves[1].length); var i = 1; while (i <= zerosNeeded) { cropped = (cropped + "0"); i++; }; return (cropped); } public static function fmt2(x:Number):String{ var s:String = (Math.round((x * 100)) / 100).toString(); return (s); } public static function dist(dx:Number, dy:Number):Number{ return (Math.sqrt(((dx * dx) + (dy * dy)))); } } }//package

Library Items

Symbol 1 Bitmap {Main_PlayerImg}
Symbol 2 Bitmap {Main_CompassImg}
Symbol 3 Bitmap {GUI.Ticks_TickImg}

Special Tags

FileAttributes (69)Timeline Frame 1Access network only, Metadata present, AS3.
SWFMetaData (77)Timeline Frame 1457 bytes "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'><rdf:Description rdf:about='' xmlns ..."
ScriptLimits (65)Timeline Frame 1MaxRecursionDepth: 1000, ScriptTimeout: 60 seconds
EnableDebugger2 (64)Timeline Frame 131 bytes "u.$1$H5$mWhEctv.dp0J9PJnxs1Ok0."
DebugMX1 (63)Timeline Frame 1
SerialNumber (41)Timeline Frame 1

Labels

"Main"Frame 1




http://swfchan.com/48/239035/info.shtml
Created: 8/1 -2021 18:55:19 Last modified: 8/1 -2021 18:55:19 Server time: 22/12 -2024 09:19:14