Section 1
//FullClippingAnalyzer (be.dauntless.astar.analyzers.FullClippingAnalyzer)
package be.dauntless.astar.analyzers {
import be.dauntless.astar.*;
public class FullClippingAnalyzer extends Analyzer {
override protected function analyze(_arg1, _arg2:Array, _arg3:Array, _arg4:IMap):Array{
var _local5:IPositionTile;
var _local6:Array;
var _local7:Number;
var _local8:IPositionTile;
_local5 = (_arg1 as IPositionTile);
_local6 = new Array();
_local7 = 0;
while (_local7 < _arg3.length) {
_local8 = (_arg3[_local7] as IPositionTile);
if ((((_local8.getPosition().x == _local5.getPosition().x)) || ((_local8.getPosition().y == _local5.getPosition().y)))){
_local6.push(_local8);
};
_local7++;
};
return (_local6);
}
override public function getTileInterface():Class{
return (IPositionTile);
}
}
}//package be.dauntless.astar.analyzers
Section 2
//WalkableAnalyzer (be.dauntless.astar.analyzers.WalkableAnalyzer)
package be.dauntless.astar.analyzers {
import be.dauntless.astar.*;
public class WalkableAnalyzer extends Analyzer {
override protected function analyze(_arg1, _arg2:Array, _arg3:Array, _arg4:IMap):Array{
var _local5:Array;
var _local6:Number;
var _local7:IWalkableTile;
_local5 = new Array();
_local6 = 0;
while (_local6 < _arg3.length) {
_local7 = (_arg3[_local6] as IWalkableTile);
if (_local7.getWalkable()){
_local5.push(_local7);
};
_local6++;
};
return (_local5);
}
override public function getTileInterface():Class{
return (IWalkableTile);
}
override public function analyzeTile(_arg1):Boolean{
return ((_arg1 as IWalkableTile).getWalkable());
}
}
}//package be.dauntless.astar.analyzers
Section 3
//Analyzer (be.dauntless.astar.Analyzer)
package be.dauntless.astar {
public class Analyzer {
protected var _subAnalyzer:Analyzer;
final function setSubAnalyzer(_arg1:Analyzer):void{
_subAnalyzer = _arg1;
}
final public function implementsInterface(_arg1):String{
var _local2:Class;
_local2 = getTileInterface();
if (((!((_local2 == null))) && (!((_arg1 is _local2))))){
return (String(getTileInterface()));
};
return (((_subAnalyzer == null)) ? "" : _subAnalyzer.implementsInterface(_arg1));
}
final function removeAnalyzer(_arg1:Analyzer):Analyzer{
if (_arg1 == this){
return (_subAnalyzer);
};
this.setSubAnalyzer(this._subAnalyzer.removeAnalyzer(_arg1));
return (this);
}
protected function analyze(_arg1, _arg2:Array, _arg3:Array, _arg4:IMap):Array{
return (_arg3);
}
final protected function getSubAnalyzer():Analyzer{
return (_subAnalyzer);
}
public function analyzeTile(_arg1):Boolean{
return (true);
}
public function getTileInterface():Class{
return (null);
}
final public function subAnalyzeTile(_arg1):Boolean{
if (!this.analyzeTile(_arg1)){
return (false);
};
return (((_subAnalyzer == null)) ? true : _subAnalyzer.subAnalyzeTile(_arg1));
}
final function subAnalyze(_arg1:DataTile, _arg2:Array, _arg3:Array, _arg4:IMap):Array{
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local8:Array;
_local5 = new Array();
_local6 = 0;
while (_local6 < _arg2.length) {
_local5.push(_arg2[_local6]);
_local6++;
};
_local7 = new Array();
_local6 = 0;
while (_local6 < _arg3.length) {
_local7.push(_arg3[_local6]);
_local6++;
};
_local8 = this.analyze(_arg1.getTarget(), _arg2, _arg3, _arg4);
if (_local8 == null){
_local8 = _local7;
};
if (this._subAnalyzer == null){
return (_local8);
};
return (this._subAnalyzer.subAnalyze(_arg1, _local5, _local8, _arg4));
}
}
}//package be.dauntless.astar
Section 4
//Astar (be.dauntless.astar.Astar)
package be.dauntless.astar {
import flash.geom.*;
import flash.events.*;
import flash.utils.*;
public class Astar extends EventDispatcher {
private var _analyzer:Analyzer;
private var _standardCost:Number;// = 1
private var _intervalTime:Number;// = 100
private var _queue:SortedQueue;
private var _end:Point;
private var _map:IMap;
private var _dictionary:Dictionary;
private var _sourceMap:IMap;
private var _heap:BinaryHeap;
private var _iterations:Number;// = 1000
private var _pathFound:Boolean;
private var _start:Point;
private var _timer:Timer;
private var _isSearching:Boolean;// = false
private var _currentRequest:PathRequest;
public static const DIAGONAL_FACTOR:Number = 1.4;
public function Astar(){
_standardCost = 1;
_iterations = 1000;
_intervalTime = 100;
_isSearching = false;
super();
_queue = new SortedQueue();
_dictionary = new Dictionary();
_analyzer = new Analyzer();
}
private function compareFValues(_arg1:DataTile, _arg2:DataTile):Number{
return ((_arg1.getF() - _arg2.getF()));
}
private function getStandardNeighbours(_arg1:Point):Array{
var _local2:Array;
var _local3:Array;
var _local4:DataTile;
var _local5:Point;
var _local6:Number;
_local2 = this._sourceMap.getNeighbours(_arg1);
_local3 = new Array();
_local4 = null;
_local5 = null;
_local6 = 0;
_local6 = 0;
while (_local6 < _local2.length) {
_local5 = (_local2[_local6] as IPositionTile).getPosition();
_local4 = this.getDataTile(_local5.x, _local5.y);
if (((!((_local4 == null))) && (!(_local4.getClosed())))){
_local3.push(_local4);
};
_local6++;
};
return (_local3);
}
private function openTile(_arg1:DataTile, _arg2:Point, _arg3:Number, _arg4:Point, _arg5:DataTile):void{
_arg1.setPosition(_arg2);
_arg1.setOpen(true);
_arg1.setG(_arg3);
_arg1.setH(_arg4);
_arg1.setParent(_arg5);
this._heap.add(_arg1);
}
public function getPath(_arg1:PathRequest):void{
ready(_arg1.getStart(), _arg1.getEnd(), _arg1.getMap());
_queue.enqueue(_arg1);
if (!_isSearching){
searchForNextPath();
};
}
public function getStandardCost():Number{
return (_standardCost);
}
private function ready(_arg1:Point, _arg2:Point, _arg3:IMap):void{
var _local4:*;
var _local5:String;
if ((((_arg1.x < 0)) || ((_arg1.x >= _arg3.getWidth())))){
abort("Start.x out of bounds");
};
if ((((_arg1.y < 0)) || ((_arg1.y >= _arg3.getHeight())))){
abort("Start.y out of bounds");
};
if ((((_arg2.x < 0)) || ((_arg2.x >= _arg3.getWidth())))){
abort("End.x out of bounds");
};
if ((((_arg2.y < 0)) || ((_arg2.y >= _arg3.getHeight())))){
abort("End.y out of bounds");
};
if ((((_arg2.x == _arg1.x)) && ((_arg2.y == _arg1.y)))){
abort("Start equals end");
};
if (!this._analyzer.subAnalyzeTile(_arg3.getTileAt(new Point(_arg1.x, _arg1.y)))){
abort("The start tile is not a valid tile");
};
_local4 = _arg3.getTileAt(new Point(_arg2.x, _arg2.y));
if (!this._analyzer.subAnalyzeTile(_local4)){
abort("The end tile is not a valid tile");
};
_local5 = this._analyzer.implementsInterface(_local4);
if (_local5 != ""){
abort((("The tiles do not implement the correct interfaces (" + _local5) + ")."));
};
}
public function setStandardCost(_arg1:Number):void{
_standardCost = _arg1;
}
private function abort(_arg1:String):void{
throw (new AstarError(_arg1));
}
private function inspectNeighbours(_arg1:DataTile, _arg2:Array):void{
var _local3:Number;
var _local4:DataTile;
var _local5:Number;
var _local6:Number;
_local3 = _arg2.length;
_local4 = null;
_local5 = 0;
_local6 = 0;
while (_local3-- > 0) {
_local4 = (_arg2[_local3] as DataTile);
_local4.setDiag(_map.isDiagonal(_arg1.getPosition(), _local4.getPosition()));
if (!_local4.getOpen()){
openTile(_local4, _local4.getPosition(), _arg1.getG(), this._end, _arg1);
} else {
_local5 = _local4.calculateUpdateF(_arg1.getG());
if (_local5 < _local4.getF()){
_local6 = this._heap.getPosition(_local4);
_local4.setParent(_arg1);
_local4.setG(_arg1.getG());
this._heap.update_heap(_local6);
};
};
};
}
private function buildPath():AstarPath{
var _local1:AstarPath;
var _local2:DataTile;
var _local3:Point;
_local1 = new AstarPath();
_local2 = this.getDataTile(_end.x, _end.y);
_local3 = _end;
while (!(_local3.equals(_start))) {
_local1.add(_local2.getTarget());
_local2 = _local2.getParent();
_local3 = _local2.getPosition();
};
_local1.add(_local2.getTarget());
return (_local1);
}
public function setIntervalTime(_arg1:Number):void{
_intervalTime = _arg1;
}
private function createDataMap():void{
var _local1:Number;
var _local2:DataTile;
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:Number;
_map = new Map(this._currentRequest.getMap().getWidth(), this._currentRequest.getMap().getHeight());
_local1 = this.getStandardCost();
_local2 = null;
_local3 = 0;
_local4 = 0;
_local5 = 0;
_local6 = 0;
_local3 = 0;
_local5 = this._sourceMap.getHeight();
while (_local3 < _local5) {
_local4 = 0;
_local6 = this._sourceMap.getWidth();
while (_local4 < _local6) {
_local2 = new DataTile(_local1);
_local2.setPosition(new Point(_local4, _local3));
_map.setTile(_local2);
_local4++;
};
_local3++;
};
}
public function setIterations(_arg1:Number):void{
_iterations = _arg1;
}
private function runCore(_arg1:TimerEvent=null):void{
var _local2:DataTile;
var _local3:Point;
var _local4:Array;
var _local5:int;
var _local6:AstarEvent;
_local3 = null;
_local4 = null;
_local5 = 0;
while ((((_local5 < _iterations)) && ((this._heap.getLength() > 0)))) {
_local2 = this._heap.shift();
_local3 = _local2.getPosition();
if ((((_local3.x == _end.x)) && ((_local3.y == _end.y)))){
_pathFound = true;
break;
};
_local2.setClosed();
_local4 = getNeighbours(_local3);
inspectNeighbours(_local2, _local4);
_local5++;
};
if ((((((_heap.getLength() == 0)) && (!(_pathFound)))) || (_pathFound))){
if (!_pathFound){
_local6 = new AstarEvent(AstarEvent.PATH_NOT_FOUND, new AstarPath(), _currentRequest);
} else {
_local6 = new AstarEvent(AstarEvent.PATH_FOUND, buildPath(), _currentRequest);
};
this._timer.stop();
this._timer.reset();
this._isSearching = false;
this.dispatchEvent(_local6);
searchForNextPath();
};
}
private function searchForNextPath():void{
if (!_queue.hasNext()){
return;
};
this._currentRequest = _queue.getNext();
_start = this._currentRequest.getStart();
_end = this._currentRequest.getEnd();
this._sourceMap = this._currentRequest.getMap();
this._isSearching = true;
this.createDataMap();
_heap = new BinaryHeap(compareFValues);
_pathFound = false;
openTile(getDataTile(_start.x, _start.y), _start, 0, _end, null);
_timer = new Timer(_intervalTime);
_timer.addEventListener(TimerEvent.TIMER, runCore);
_timer.start();
runCore();
}
public function addAnalyzer(_arg1:Analyzer):void{
_arg1.setSubAnalyzer(_analyzer);
this._analyzer = _arg1;
}
private function getDataTile(_arg1:int, _arg2:int):DataTile{
var _local3:DataTile;
_local3 = null;
if ((((((((_arg1 < 0)) || ((_arg2 < 0)))) || ((_arg1 >= _sourceMap.getWidth())))) || ((_arg2 >= _sourceMap.getHeight())))){
return (null);
};
if (DataTile(_map.getTileAt(new Point(_arg1, _arg2))).getTarget() == null){
_local3 = new DataTile(this.getStandardCost());
_local3.setPosition(new Point(_arg1, _arg2));
_local3.setTarget(_sourceMap.getTileAt(new Point(_arg1, _arg2)));
_map.setTile(_local3);
};
return (DataTile(_map.getTileAt(new Point(_arg1, _arg2))));
}
private function getNeighbours(_arg1:Point):Array{
var _local2:Array;
var _local3:Array;
var _local4:DataTile;
var _local5:int;
var _local6:Array;
var _local7:Array;
_local2 = getStandardNeighbours(_arg1);
_local3 = new Array();
_local4 = null;
_dictionary = new Dictionary();
_local5 = 0;
while (_local5 < _local2.length) {
_local4 = (_local2[_local5] as DataTile);
this._dictionary[_local4.getTarget()] = (_local2[_local5] as DataTile);
_local3.push(_local4.getTarget());
_local5++;
};
_local6 = _analyzer.subAnalyze(getDataTile(_arg1.x, _arg1.y), _local3, _local3, _sourceMap);
_local7 = new Array();
_local5 = 0;
while (_local5 < _local6.length) {
_local7.push(_dictionary[_local6[_local5]]);
_local5++;
};
return (_local7);
}
}
}//package be.dauntless.astar
Section 5
//AstarError (be.dauntless.astar.AstarError)
package be.dauntless.astar {
public class AstarError extends Error {
public function AstarError(_arg1:String, _arg2:int=0){
super(_arg1, _arg2);
}
public function toString():String{
return (((("AStarError[" + errorID) + "] message: ") + message));
}
}
}//package be.dauntless.astar
Section 6
//AstarEvent (be.dauntless.astar.AstarEvent)
package be.dauntless.astar {
import flash.events.*;
public class AstarEvent extends Event {
private var path:AstarPath;
private var request:PathRequest;
public static const PATH_FOUND:String = "pathFound";
public static const PATH_NOT_FOUND:String = "pathNotFound";
public function AstarEvent(_arg1:String, _arg2:AstarPath, _arg3:PathRequest, _arg4:Boolean=false, _arg5:Boolean=false){
super(_arg1, _arg4, _arg5);
this.path = _arg2;
this.request = _arg3;
}
public function getRequest():PathRequest{
return (request);
}
public function getPath():AstarPath{
return (path);
}
override public function clone():Event{
return (new AstarEvent(this.type, this.path, this.request, this.bubbles, this.cancelable));
}
}
}//package be.dauntless.astar
Section 7
//AstarPath (be.dauntless.astar.AstarPath)
package be.dauntless.astar {
import flash.geom.*;
public class AstarPath implements IIterator {
private var _path:Array;
private var position:Number;// = 0
public function AstarPath(){
position = 0;
super();
_path = new Array();
}
function add(_arg1:IPositionTile):void{
this._path.splice(0, 0, _arg1);
}
public function toArray():Array{
return (_path.slice());
}
public function toString():String{
var _local1:String;
var _local2:Number;
var _local3:Point;
_local1 = "AstarPath: ";
_local2 = 0;
while (_local2 < _path.length) {
_local3 = (_path[_local2] as IPositionTile).getPosition();
_local1 = (_local1 + (((("(" + _local3.x) + ",") + _local3.y) + ")"));
if (_local2 < (_path.length - 1)){
_local1 = (_local1 + ",");
};
_local2++;
};
return (_local1);
}
public function hasNext():Boolean{
return ((position < _path.length));
}
public function reset():void{
position = 0;
}
public function getNext():IPositionTile{
if (!hasNext()){
return (null);
};
return (_path[position++]);
}
public function peek():IPositionTile{
if (!hasNext()){
return (null);
};
return (_path[position]);
}
}
}//package be.dauntless.astar
Section 8
//BasicTile (be.dauntless.astar.BasicTile)
package be.dauntless.astar {
import flash.geom.*;
public class BasicTile implements IPositionTile, IWalkableTile, ICostTile {
private var walkable:Boolean;
private var position:Point;
private var cost:Number;
public function BasicTile(_arg1:Number, _arg2:Point, _arg3:Boolean){
this.cost = _arg1;
this.position = _arg2;
this.walkable = _arg3;
}
public function setWalkable(_arg1:Boolean):void{
this.walkable = _arg1;
}
public function getCost():Number{
return (cost);
}
public function setPosition(_arg1:Point):void{
position = _arg1;
}
public function getPosition():Point{
return (position);
}
public function setCost(_arg1:Number):void{
this.cost = _arg1;
}
public function getWalkable():Boolean{
return (walkable);
}
}
}//package be.dauntless.astar
Section 9
//BinaryHeap (be.dauntless.astar.BinaryHeap)
package be.dauntless.astar {
public class BinaryHeap {
private var _compare:Function;
private var _heap:Array;
public function BinaryHeap(_arg1:Function=null){
var p_compare = _arg1;
super();
if (p_compare == null){
this._compare = function (_arg1:Number, _arg2:Number):Number{
return ((_arg1 - _arg2));
};
} else {
this._compare = p_compare;
};
_heap = new Array(null);
}
public function hasElement(_arg1):Boolean{
var _local2:Number;
_local2 = _heap.length;
while (_local2-- > 0) {
if (_heap[_local2] == _arg1){
return (true);
};
};
return (false);
}
public function add(_arg1):void{
var _local2:Number;
var _local3:Number;
var _local4:*;
_heap.push(_arg1);
_local2 = (_heap.length - 1);
while (_local2 != 1) {
_local3 = Math.floor((_local2 / 2));
if (_compare(_heap[_local2], _heap[_local3]) <= 0){
_local4 = _heap[_local3];
_heap[_local3] = _heap[_local2];
_heap[_local2] = _local4;
_local2 = _local3;
} else {
break;
};
};
}
public function shift(){
var _local1:*;
_local1 = _heap[1];
if (_heap.length == 2){
_heap.pop();
} else {
_heap[1] = _heap.pop();
};
crawlDown(1);
return (_local1);
}
private function crawlDown(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:*;
_local2 = _arg1;
while (true) {
_local3 = _local2;
_local4 = (2 * _local3);
if ((_local4 - -1) <= (_heap.length - 1)){
if (_compare(_heap[_local3], _heap[_local4]) >= 0){
_local2 = _local4;
};
if (_compare(_heap[_local2], _heap[(_local4 - -1)]) >= 0){
_local2 = (_local4 - -1);
};
} else {
if (_local4 <= (_heap.length - 1)){
if (_compare(_heap[_local3], _heap[_local4]) >= 0){
_local2 = _local4;
};
};
};
if (_local3 != _local2){
_local5 = _heap[_local3];
_heap[_local3] = _heap[_local2];
_heap[_local2] = _local5;
} else {
break;
};
};
}
private function crawlUp(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:*;
var _local5:*;
var _local6:*;
_local2 = _arg1;
while (_local2 != 1) {
_local3 = Math.floor((_local2 / 2));
_local4 = _heap[_local2];
_local5 = _heap[_local3];
if (_compare(_local4, _local5) <= 0){
_local6 = _local5;
_heap[_local3] = _local4;
_heap[_local2] = _local6;
_local2 = _local3;
} else {
break;
};
};
}
public function getLowest(){
return (_heap[1]);
}
public function update_heap(_arg1:Number):void{
if ((((_arg1 > 1)) && ((_compare(_heap[_arg1], _heap[Math.floor((_arg1 / 2))]) <= 0)))){
crawlUp(_arg1);
} else {
crawlDown(_arg1);
};
}
public function getLength():Number{
return ((_heap.length - 1));
}
public function toArray():Array{
return (_heap);
}
public function getPosition(_arg1):Number{
var _local2:Number;
_local2 = 1;
while (_local2 < _heap.length) {
if (_heap[_local2] == _arg1){
return (_local2);
};
_local2++;
};
return (-1);
}
}
}//package be.dauntless.astar
Section 10
//DataTile (be.dauntless.astar.DataTile)
package be.dauntless.astar {
import be.dauntless.astar.*;
import flash.geom.*;
class DataTile implements IPositionTile {
private var multiplier:Number;// = 1
public var _standardCost:Number;
private var open:Boolean;
private var target;
private var f:Number;
private var g:Number;
private var h:Number;
private var position:Point;
private var parent:DataTile;
private var closed:Boolean;
function DataTile(_arg1:Number){
multiplier = 1;
super();
_standardCost = _arg1;
}
public function getOpen():Boolean{
return (open);
}
public function getTarget(){
return (target);
}
public function setTarget(_arg1):void{
this.target = _arg1;
}
public function calculateUpdateF(_arg1:Number):Number{
return (((this.getCost() + _arg1) + getH()));
}
public function getPosition():Point{
return (position);
}
public function getParent():DataTile{
return (parent);
}
public function setOpen(_arg1:Boolean):void{
this.open = _arg1;
}
public function setG(_arg1:Number):void{
this.g = (_arg1 + getCost());
this.f = (this.h + this.g);
}
public function setPosition(_arg1:Point):void{
this.position = _arg1;
}
public function setH(_arg1:Point):void{
this.h = ((Math.abs((_arg1.x - position.x)) * _standardCost) + (Math.abs((_arg1.y - position.y)) * _standardCost));
this.f = (this.h + this.g);
}
public function setClosed():void{
this.closed = true;
}
public function getF():Number{
return (this.f);
}
public function getG():Number{
return (g);
}
public function getH():Number{
return (h);
}
public function setDiag(_arg1:Boolean):void{
multiplier = (_arg1) ? Astar.DIAGONAL_FACTOR : 1;
}
public function getClosed():Boolean{
return (closed);
}
public function setParent(_arg1:DataTile):void{
this.parent = _arg1;
}
public function getCost():Number{
if ((target is ICostTile)){
return ((ICostTile(target).getCost() * multiplier));
};
return ((this._standardCost * multiplier));
}
}
}//package be.dauntless.astar
Section 11
//ICostTile (be.dauntless.astar.ICostTile)
package be.dauntless.astar {
public interface ICostTile {
function getCost():Number;
function setCost(_arg1:Number):void;
}
}//package be.dauntless.astar
Section 12
//IIterator (be.dauntless.astar.IIterator)
package be.dauntless.astar {
public interface IIterator {
function getNext():IPositionTile;
function peek():IPositionTile;
function hasNext():Boolean;
function reset():void;
}
}//package be.dauntless.astar
Section 13
//IMap (be.dauntless.astar.IMap)
package be.dauntless.astar {
import flash.geom.*;
public interface IMap {
function setTile(_arg1:IPositionTile):void;
function setSize(_arg1:Number, _arg2:Number):void;
function isDiagonal(_arg1:Point, _arg2:Point):Boolean;
function getTileAt(_arg1:Point):IPositionTile;
function getWidth():Number;
function getNeighbours(_arg1:Point):Array;
function getHeight():Number;
}
}//package be.dauntless.astar
Section 14
//IPositionTile (be.dauntless.astar.IPositionTile)
package be.dauntless.astar {
import flash.geom.*;
public interface IPositionTile {
function setPosition(_arg1:Point):void;
function getPosition():Point;
}
}//package be.dauntless.astar
Section 15
//IWalkableTile (be.dauntless.astar.IWalkableTile)
package be.dauntless.astar {
public interface IWalkableTile {
function setWalkable(_arg1:Boolean):void;
function getWalkable():Boolean;
}
}//package be.dauntless.astar
Section 16
//Map (be.dauntless.astar.Map)
package be.dauntless.astar {
import flash.geom.*;
public class Map implements IMap {
private var _map:Array;
public function Map(_arg1:Number, _arg2:Number){
this.setSize(_arg1, _arg2);
}
public function setSize(_arg1:Number, _arg2:Number):void{
var _local3:Number;
_map = new Array(_arg2);
_local3 = 0;
while (_local3 < _arg2) {
_map[_local3] = new Array(_arg1);
_local3++;
};
}
public function isDiagonal(_arg1:Point, _arg2:Point):Boolean{
return (((!((_arg1.x == _arg2.x))) && (!((_arg1.y == _arg2.y)))));
}
public function getWidth():Number{
return (((_map)==null) ? -1 : (_map[0] as Array).length);
}
public function getNeighbours(_arg1:Point):Array{
var _local2:Number;
var _local3:Number;
var _local4:Array;
_local2 = _arg1.x;
_local3 = _arg1.y;
_local4 = new Array();
if (this.isValidPosition(new Point((_local2 - 1), (_local3 - 1)))){
_local4.push(this.getTileAt(new Point((_local2 - 1), (_local3 - 1))));
};
if (this.isValidPosition(new Point((_local2 - 1), _local3))){
_local4.push(this.getTileAt(new Point((_local2 - 1), _local3)));
};
if (this.isValidPosition(new Point((_local2 - 1), (_local3 + 1)))){
_local4.push(this.getTileAt(new Point((_local2 - 1), (_local3 + 1))));
};
if (this.isValidPosition(new Point(_local2, (_local3 - 1)))){
_local4.push(this.getTileAt(new Point(_local2, (_local3 - 1))));
};
if (this.isValidPosition(new Point(_local2, (_local3 + 1)))){
_local4.push(this.getTileAt(new Point(_local2, (_local3 + 1))));
};
if (this.isValidPosition(new Point((_local2 + 1), (_local3 - 1)))){
_local4.push(this.getTileAt(new Point((_local2 + 1), (_local3 - 1))));
};
if (this.isValidPosition(new Point((_local2 + 1), _local3))){
_local4.push(this.getTileAt(new Point((_local2 + 1), _local3)));
};
if (this.isValidPosition(new Point((_local2 + 1), (_local3 + 1)))){
_local4.push(this.getTileAt(new Point((_local2 + 1), (_local3 + 1))));
};
return (_local4);
}
public function setTile(_arg1:IPositionTile):void{
var _local2:Point;
_local2 = _arg1.getPosition();
if (isValidPosition(_local2)){
_map[_local2.y][_local2.x] = _arg1;
};
}
public function isValidPosition(_arg1:Point):Boolean{
if (_map == null){
return (false);
};
if ((((_arg1.x < 0)) || ((_arg1.y < 0)))){
return (false);
};
if ((((_arg1.x >= this.getWidth())) || ((_arg1.y >= this.getHeight())))){
return (false);
};
return (true);
}
public function getHeight():Number{
return (((_map)==null) ? -1 : _map.length);
}
public function getTileAt(_arg1:Point):IPositionTile{
if (isValidPosition(_arg1)){
return (_map[_arg1.y][_arg1.x]);
};
return (null);
}
}
}//package be.dauntless.astar
Section 17
//PathRequest (be.dauntless.astar.PathRequest)
package be.dauntless.astar {
import flash.geom.*;
public class PathRequest {
private var _priority:uint;
private var _start:Point;
private var _end:Point;
private var _map:IMap;
public function PathRequest(_arg1:Point, _arg2:Point, _arg3:IMap, _arg4:uint=10){
if (_arg1 == null){
throw (new AstarError("Invalid start point"));
};
if (_arg2 == null){
throw (new AstarError("Invalid end point"));
};
if (_arg3 == null){
throw (new AstarError("Invalid map point"));
};
this._start = _arg1;
this._end = _arg2;
this._priority = _arg4;
this._map = _arg3;
}
public function setStart(_arg1:Point):void{
_start = _arg1;
}
public function get priority():uint{
return (_priority);
}
public function getEnd():Point{
return (_end);
}
public function set priority(_arg1:uint):void{
_priority = _arg1;
}
public function setMap(_arg1:IMap):void{
_map = _arg1;
}
public function getStart():Point{
return (_start);
}
public function getMap():IMap{
return (_map);
}
public function setEnd(_arg1:Point):void{
_end = _arg1;
}
}
}//package be.dauntless.astar
Section 18
//SortedQueue (be.dauntless.astar.SortedQueue)
package be.dauntless.astar {
public class SortedQueue {
private var _queue:Array;
public function SortedQueue(){
_queue = new Array();
}
public function enqueue(_arg1:PathRequest):void{
_queue.push(_arg1);
_queue.sortOn("priority", Array.NUMERIC);
}
public function getNext():PathRequest{
var _local1:PathRequest;
if (!hasNext()){
return (null);
};
_local1 = _queue.shift();
return (_local1);
}
public function peek():PathRequest{
if (!hasNext()){
return (null);
};
return (_queue[0]);
}
public function hasNext():Boolean{
return ((_queue.length > 0));
}
}
}//package be.dauntless.astar
Section 19
//MainTimeline (main_fla.MainTimeline)
package main_fla {
import flash.geom.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.display.*;
import flash.text.*;
import flash.net.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.printing.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public var oke:Boolean;
public var JumlahLevel;
public var PosisiLSy;
public var PosisiLSx;
public var tulsta:MovieClip;
public var bg_utama:MovieClip;
public var skorket:MovieClip;
public var percent:Number;
public var toret:SimpleButton;
public var so:SharedObject;
public var StageSekarang:Number;
public var i;
public var StageBoleh:Array;
public var digit_10:MovieClip;
public var skiper:SimpleButton;
public var digit_13:MovieClip;
public var digit_14:MovieClip;
public var digit_15:MovieClip;
public var digit_16:MovieClip;
public var digit_17:MovieClip;
public var digit_18:MovieClip;
public var tempat_level_selector:MovieClip;
public var digit_20:MovieClip;
public var digit_21:MovieClip;
public var digit_11:MovieClip;
public var digit_25:MovieClip;
public var JumlahKolomLevel;
public var digit_22:MovieClip;
public var digit_23:MovieClip;
public var digit_24:MovieClip;
public var tomsuara:MovieClip;
public var posisipenunjuk;
public var digit_19:MovieClip;
public var bulan_limit;
public var digit_12:MovieClip;
public var tombol_simpan_nama:SimpleButton;
public var spolo:SimpleButton;
public var utama:YS;
public var NamaPemain;
public var suara;
public var tombol_copyright_mc:MovieClip;
public var tampil_hs_nama_1:TextField;
public var tampil_hs_nama_9:TextField;
public var tampil_hs_nama_6:TextField;
public var tampil_hs_nama_8:TextField;
public var input_nama_pemain:TextField;
public var varLS:LevelSelector;
public var tampil_hs_nama_7:TextField;
public var tampil_hs_nama_5:TextField;
public var lebih;
public var tampil_hs_nama_3:TextField;
public var tampil_hs_nama_4:TextField;
public var format1:TextFormat;
public var tampil_hs_nama_2:TextField;
public var format2:TextFormat;
public var preloader_bar_mc:MovieClip;
public var tampil_hs_skor_10:TextField;
public var WebSponsor;
public var cling_musik:musik;
public var tahun_limit;
public var JedaAntarLevel;
public var tampil_hs_nama_10:TextField;
public var tombol_play_mc:SimpleButton;
public var cling_se:se;
public var CopyrightSite;
public var tampil_hs_skor_1:TextField;
public var tampil_hs_skor_3:TextField;
public var tampil_hs_skor_4:TextField;
public var tampil_hs_skor_5:TextField;
public var tampil_hs_skor_6:TextField;
public var tampil_hs_skor_7:TextField;
public var tampil_hs_skor_8:TextField;
public var tampil_hs_skor_9:TextField;
public var digit_0:MovieClip;
public var digit_1:MovieClip;
public var digit_2:MovieClip;
public var digit_3:MovieClip;
public var tombol_main_menu:SimpleButton;
public var digit_6:MovieClip;
public var digit_8:MovieClip;
public var digit_9:MovieClip;
public var stale:MovieClip;
public var digit_4:MovieClip;
public var savscore:MovieClip;
public var digit_7:MovieClip;
public var sudahdicekhs;
public var SkorTotal;
public var digit_5:MovieClip;
public var tampil_hs_skor_2:TextField;
public var tombol_hs_mc:SimpleButton;
public var SpeakerLain:SoundChannel;
public var Speaker:SoundChannel;
public var TampungPosisiLSy;
public var adadihs;
public var tanggal_limit;
public var tombol_more_games_mc:SimpleButton;
public var animasi_sponsor_mc:MovieClip;
public var TampungPosisiLSx;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8, 8, frame9);
}
public function startHighscore(_arg1:MouseEvent){
MovieClip(root).gotoAndStop(4);
}
public function simpanNama(_arg1:MouseEvent){
NamaPemain = input_nama_pemain.text;
}
public function keReset(_arg1:Event){
utama.resetlah();
if (StageSekarang <= JumlahLevel){
gotoAndStop(7);
} else {
gotoAndStop(8);
};
}
public function keMainMenu(_arg1:MouseEvent){
MovieClip(root).gotoAndStop(3);
}
public function gotoSponsor(_arg1:MouseEvent){
var _local2:URLRequest;
_local2 = new URLRequest(WebSponsor);
navigateToURL(_local2, "_blank");
}
public function updateLevel(){
var _local1:*;
_local1 = 1;
while (_local1 <= JumlahLevel) {
if (_local1 <= so.data.StageSekarang){
StageBoleh[_local1] = true;
};
_local1++;
};
}
function frame2(){
stop();
WebSponsor = "http://www.ichwillspielen.com/?index=43";
CopyrightSite = "http://www.yohanessuyanto.com";
JumlahLevel = 8;
JedaAntarLevel = 45;
JumlahKolomLevel = 4;
animasi_sponsor_mc.buttonMode = true;
animasi_sponsor_mc.addEventListener(MouseEvent.CLICK, gotoSponsor);
StageSekarang = 0;
StageBoleh = new Array();
i = 1;
while (i <= JumlahLevel) {
StageBoleh[i] = false;
i++;
};
NamaPemain = "Your Name";
SkorTotal = 0;
so = SharedObject.getLocal("YSHighScoreMMatch");
if (so.data.StageSekarang){
StageSekarang = so.data.StageSekarang;
} else {
so.data.StageSekarang = 1;
StageSekarang = so.data.StageSekarang;
so.data.namahs1 = "No Name";
so.data.namahs2 = "No Name";
so.data.namahs3 = "No Name";
so.data.namahs4 = "No Name";
so.data.namahs5 = "No Name";
so.data.namahs6 = "No Name";
so.data.namahs7 = "No Name";
so.data.namahs8 = "No Name";
so.data.namahs9 = "No Name";
so.data.namahs10 = "No Name";
so.data.skorhs1 = 1800;
so.data.skorhs2 = 1700;
so.data.skorhs3 = 1600;
so.data.skorhs4 = 1500;
so.data.skorhs5 = 1400;
so.data.skorhs6 = 1300;
so.data.skorhs7 = 1200;
so.data.skorhs8 = 1100;
so.data.skorhs9 = 1000;
so.data.skorhs10 = 999;
};
so.flush();
updateLevel();
format1 = new TextFormat();
format1.font = "Arial";
format1.color = 13615698;
format1.size = 10;
format2 = new TextFormat();
format2.font = "Arial";
format2.color = 0xFFFFFF;
format2.size = 10;
sudahdicekhs = false;
adadihs = false;
posisipenunjuk = 0;
suara = true;
tomsuara.addEventListener(MouseEvent.CLICK, gantiSuara);
tomsuara.buttonMode = true;
cling_musik = new musik();
cling_se = new se();
mainkanLagu();
tanggal_limit = 31;
bulan_limit = 9;
tahun_limit = 2010;
lebih = false;
if (compareDates(tahun_limit, bulan_limit, tanggal_limit)){
lebih = true;
};
if (!lebih){
gotoAndStop(3);
};
}
function frame4(){
if (suara){
tomsuara.gotoAndStop(1);
} else {
tomsuara.gotoAndStop(2);
};
tombol_main_menu.addEventListener(MouseEvent.CLICK, keMainMenu);
if (!sudahdicekhs){
adadihs = false;
posisipenunjuk = 0;
if (SkorTotal > so.data.skorhs1){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = so.data.skorhs7;
so.data.skorhs7 = so.data.skorhs6;
so.data.skorhs6 = so.data.skorhs5;
so.data.skorhs5 = so.data.skorhs4;
so.data.skorhs4 = so.data.skorhs3;
so.data.skorhs3 = so.data.skorhs2;
so.data.skorhs2 = so.data.skorhs1;
so.data.skorhs1 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = so.data.namahs7;
so.data.namahs7 = so.data.namahs6;
so.data.namahs6 = so.data.namahs5;
so.data.namahs5 = so.data.namahs4;
so.data.namahs4 = so.data.namahs3;
so.data.namahs3 = so.data.namahs2;
so.data.namahs2 = so.data.namahs1;
so.data.namahs1 = NamaPemain;
posisipenunjuk = 1;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs2){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = so.data.skorhs7;
so.data.skorhs7 = so.data.skorhs6;
so.data.skorhs6 = so.data.skorhs5;
so.data.skorhs5 = so.data.skorhs4;
so.data.skorhs4 = so.data.skorhs3;
so.data.skorhs3 = so.data.skorhs2;
so.data.skorhs2 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = so.data.namahs7;
so.data.namahs7 = so.data.namahs6;
so.data.namahs6 = so.data.namahs5;
so.data.namahs5 = so.data.namahs4;
so.data.namahs4 = so.data.namahs3;
so.data.namahs3 = so.data.namahs2;
so.data.namahs2 = NamaPemain;
posisipenunjuk = 2;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs3){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = so.data.skorhs7;
so.data.skorhs7 = so.data.skorhs6;
so.data.skorhs6 = so.data.skorhs5;
so.data.skorhs5 = so.data.skorhs4;
so.data.skorhs4 = so.data.skorhs3;
so.data.skorhs3 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = so.data.namahs7;
so.data.namahs7 = so.data.namahs6;
so.data.namahs6 = so.data.namahs5;
so.data.namahs5 = so.data.namahs4;
so.data.namahs4 = so.data.namahs3;
so.data.namahs3 = NamaPemain;
posisipenunjuk = 3;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs4){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = so.data.skorhs7;
so.data.skorhs7 = so.data.skorhs6;
so.data.skorhs6 = so.data.skorhs5;
so.data.skorhs5 = so.data.skorhs4;
so.data.skorhs4 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = so.data.namahs7;
so.data.namahs7 = so.data.namahs6;
so.data.namahs6 = so.data.namahs5;
so.data.namahs5 = so.data.namahs4;
so.data.namahs4 = NamaPemain;
posisipenunjuk = 4;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs5){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = so.data.skorhs7;
so.data.skorhs7 = so.data.skorhs6;
so.data.skorhs6 = so.data.skorhs5;
so.data.skorhs5 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = so.data.namahs7;
so.data.namahs7 = so.data.namahs6;
so.data.namahs6 = so.data.namahs5;
so.data.namahs5 = NamaPemain;
posisipenunjuk = 5;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs6){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = so.data.skorhs7;
so.data.skorhs7 = so.data.skorhs6;
so.data.skorhs6 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = so.data.namahs7;
so.data.namahs7 = so.data.namahs6;
so.data.namahs6 = NamaPemain;
posisipenunjuk = 6;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs7){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = so.data.skorhs7;
so.data.skorhs7 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = so.data.namahs7;
so.data.namahs7 = NamaPemain;
posisipenunjuk = 7;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs8){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = so.data.skorhs8;
so.data.skorhs8 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = so.data.namahs8;
so.data.namahs8 = NamaPemain;
posisipenunjuk = 8;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs9){
so.data.skorhs10 = so.data.skorhs9;
so.data.skorhs9 = SkorTotal;
so.data.namahs10 = so.data.namahs9;
so.data.namahs9 = NamaPemain;
posisipenunjuk = 9;
adadihs = true;
} else {
if (SkorTotal > so.data.skorhs10){
so.data.skorhs10 = SkorTotal;
so.data.namahs10 = NamaPemain;
posisipenunjuk = 10;
adadihs = true;
};
};
};
};
};
};
};
};
};
};
SkorTotal = 0;
sudahdicekhs = true;
};
tampil_hs_nama_1.text = so.data.namahs1;
tampil_hs_nama_2.text = so.data.namahs2;
tampil_hs_nama_3.text = so.data.namahs3;
tampil_hs_nama_4.text = so.data.namahs4;
tampil_hs_nama_5.text = so.data.namahs5;
tampil_hs_nama_6.text = so.data.namahs6;
tampil_hs_nama_7.text = so.data.namahs7;
tampil_hs_nama_8.text = so.data.namahs8;
tampil_hs_nama_9.text = so.data.namahs9;
tampil_hs_nama_10.text = so.data.namahs10;
tampil_hs_skor_1.text = so.data.skorhs1;
tampil_hs_skor_2.text = so.data.skorhs2;
tampil_hs_skor_3.text = so.data.skorhs3;
tampil_hs_skor_4.text = so.data.skorhs4;
tampil_hs_skor_5.text = so.data.skorhs5;
tampil_hs_skor_6.text = so.data.skorhs6;
tampil_hs_skor_7.text = so.data.skorhs7;
tampil_hs_skor_8.text = so.data.skorhs8;
tampil_hs_skor_9.text = so.data.skorhs9;
tampil_hs_skor_10.text = so.data.skorhs10;
gantiWarna(tampil_hs_nama_1, tampil_hs_skor_1, 1);
gantiWarna(tampil_hs_nama_2, tampil_hs_skor_2, 2);
gantiWarna(tampil_hs_nama_3, tampil_hs_skor_3, 3);
gantiWarna(tampil_hs_nama_4, tampil_hs_skor_4, 4);
gantiWarna(tampil_hs_nama_5, tampil_hs_skor_5, 5);
gantiWarna(tampil_hs_nama_6, tampil_hs_skor_6, 6);
gantiWarna(tampil_hs_nama_7, tampil_hs_skor_7, 7);
gantiWarna(tampil_hs_nama_8, tampil_hs_skor_8, 8);
gantiWarna(tampil_hs_nama_9, tampil_hs_skor_9, 9);
gantiWarna(tampil_hs_nama_10, tampil_hs_skor_10, 10);
}
function frame5(){
if (suara){
tomsuara.gotoAndStop(1);
} else {
tomsuara.gotoAndStop(2);
};
tombol_main_menu.addEventListener(MouseEvent.CLICK, keMainMenu);
PosisiLSx = 0;
PosisiLSy = 0;
TampungPosisiLSx = PosisiLSx;
TampungPosisiLSy = PosisiLSy;
i = 0;
while (i < JumlahLevel) {
varLS = new LevelSelector();
tempat_level_selector.addChild(varLS);
varLS.stage_ke = (i + 1);
if ((i % JumlahKolomLevel) == 0){
TampungPosisiLSx = PosisiLSx;
TampungPosisiLSy = (PosisiLSy + ((varLS.height + JedaAntarLevel) * (i / JumlahKolomLevel)));
};
varLS.x = (TampungPosisiLSx + ((i % JumlahKolomLevel) * (varLS.width + JedaAntarLevel)));
varLS.y = TampungPosisiLSy;
varLS.tulisan_level.text = String(varLS.stage_ke);
if (!StageBoleh[varLS.stage_ke]){
varLS.gotoAndStop(2);
varLS.buttonMode = false;
};
i++;
};
}
public function keMainMenuX(_arg1:Event){
SkorTotal = MovieClip(root).utama.skor_sementara;
if (SkorTotal > 0){
savscore.visible = true;
} else {
utama.resetlah();
gotoAndStop(3);
};
}
function frame9(){
sudahdicekhs = false;
gotoAndStop(4);
}
function frame1(){
oke = false;
oke = true;
loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
percent = Math.floor(((this.loaderInfo.bytesLoaded * 100) / this.loaderInfo.bytesTotal));
if (percent == 100){
MovieClip(root).gotoAndStop(2);
} else {
preloader_bar_mc.scaleX = (percent / 100);
};
stop();
}
function frame8(){
if (suara){
tomsuara.gotoAndStop(1);
} else {
tomsuara.gotoAndStop(2);
};
stop();
stage.addEventListener(MouseEvent.CLICK, keSubmitScorex);
}
function frame7(){
gotoAndStop(6);
}
function frame3(){
if (suara){
tomsuara.gotoAndStop(1);
} else {
tomsuara.gotoAndStop(2);
};
SkorTotal = 0;
tombol_play_mc.addEventListener(MouseEvent.CLICK, startGame);
tombol_hs_mc.addEventListener(MouseEvent.CLICK, startHighscore);
tombol_more_games_mc.addEventListener(MouseEvent.CLICK, gotoSponsor);
tombol_copyright_mc.addEventListener(MouseEvent.CLICK, gotoCopyright);
tombol_copyright_mc.buttonMode = true;
if (!lebih){
tombol_more_games_mc.visible = false;
};
input_nama_pemain.text = NamaPemain;
tombol_simpan_nama.addEventListener(MouseEvent.CLICK, simpanNama);
}
public function compareDates(_arg1, _arg2, _arg3){
var _local4:Date;
var _local5:Date;
_local4 = new Date();
_local5 = new Date(_arg1, _arg2, _arg3);
if (_local5 > _local4){
return (false);
};
return (true);
}
public function update(_arg1:ProgressEvent):void{
var _local2:Number;
_local2 = Math.floor(((_arg1.bytesLoaded * 100) / _arg1.bytesTotal));
if ((preloader_bar_mc is MovieClip)){
preloader_bar_mc.scaleX = (_local2 / 100);
};
if (_local2 == 100){
MovieClip(root).gotoAndStop(2);
};
}
function frame6(){
if (suara){
tomsuara.gotoAndStop(1);
} else {
tomsuara.gotoAndStop(2);
};
savscore.visible = false;
spolo.addEventListener(MouseEvent.CLICK, gotoSponsor);
if (!lebih){
spolo.visible = false;
};
tombol_main_menu.addEventListener(MouseEvent.CLICK, keMainMenuX);
toret.addEventListener(MouseEvent.CLICK, keReset);
skiper.addEventListener(MouseEvent.CLICK, keReset);
bg_utama.gotoAndStop(StageSekarang);
tulsta.gotoAndStop(StageSekarang);
stale.isi.gotoAndStop(StageSekarang);
stale.gotoAndPlay(2);
skiper.visible = false;
utama.premulai();
utama.mulai();
}
public function mainkanLagu(){
Speaker = cling_musik.play(0, 999999);
}
public function keSubmitScorex(_arg1:MouseEvent){
stage.removeEventListener(MouseEvent.CLICK, keSubmitScorex);
gotoAndStop(9);
}
public function startGame(_arg1:MouseEvent){
MovieClip(root).gotoAndStop(5);
}
public function gotoCopyright(_arg1:MouseEvent){
var _local2:URLRequest;
_local2 = new URLRequest(CopyrightSite);
navigateToURL(_local2, "_blank");
}
public function gantiWarna(_arg1, _arg2, _arg3){
if (posisipenunjuk == _arg3){
_arg1.setTextFormat(format1);
_arg2.setTextFormat(format1);
} else {
_arg1.setTextFormat(format2);
_arg2.setTextFormat(format2);
};
}
public function gantiSuara(_arg1:MouseEvent){
suara = !(suara);
if (suara){
mainkanLagu();
tomsuara.gotoAndStop(1);
} else {
if (Speaker){
Speaker.stop();
};
tomsuara.gotoAndStop(2);
};
}
}
}//package main_fla
Section 20
//sponsor_2 (main_fla.sponsor_2)
package main_fla {
import flash.display.*;
public dynamic class sponsor_2 extends MovieClip {
public function sponsor_2(){
addFrameScript(79, frame80);
}
function frame80(){
MovieClip(root).gotoAndStop(3);
stop();
}
}
}//package main_fla
Section 21
//Symbol14_24 (main_fla.Symbol14_24)
package main_fla {
import flash.display.*;
public dynamic class Symbol14_24 extends MovieClip {
public function Symbol14_24(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 22
//Symbol16_26 (main_fla.Symbol16_26)
package main_fla {
import flash.display.*;
public dynamic class Symbol16_26 extends MovieClip {
public var isi:MovieClip;
public function Symbol16_26(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 23
//Symbol17_27 (main_fla.Symbol17_27)
package main_fla {
import flash.display.*;
public dynamic class Symbol17_27 extends MovieClip {
public function Symbol17_27(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 24
//Symbol19_22 (main_fla.Symbol19_22)
package main_fla {
import flash.display.*;
public dynamic class Symbol19_22 extends MovieClip {
public function Symbol19_22(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 25
//Symbol2_40 (main_fla.Symbol2_40)
package main_fla {
import flash.display.*;
public dynamic class Symbol2_40 extends MovieClip {
public function Symbol2_40(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 26
//Symbol21_29 (main_fla.Symbol21_29)
package main_fla {
import flash.display.*;
public dynamic class Symbol21_29 extends MovieClip {
public var isi:MovieClip;
public function Symbol21_29(){
addFrameScript(0, frame1, 59, frame60);
}
function frame1(){
stop();
}
function frame60(){
visible = false;
}
}
}//package main_fla
Section 27
//Symbol22_30 (main_fla.Symbol22_30)
package main_fla {
import flash.display.*;
public dynamic class Symbol22_30 extends MovieClip {
public function Symbol22_30(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 28
//Symbol23_4 (main_fla.Symbol23_4)
package main_fla {
import flash.display.*;
public dynamic class Symbol23_4 extends MovieClip {
public function Symbol23_4(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 29
//Symbol24_7 (main_fla.Symbol24_7)
package main_fla {
import flash.display.*;
public dynamic class Symbol24_7 extends MovieClip {
public function Symbol24_7(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 30
//Symbol26_32 (main_fla.Symbol26_32)
package main_fla {
import flash.geom.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.display.*;
import flash.text.*;
import flash.net.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.printing.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class Symbol26_32 extends MovieClip {
public var ayes:SimpleButton;
public var ano:SimpleButton;
public function Symbol26_32(){
addFrameScript(0, frame1);
}
public function siScore(_arg1:MouseEvent){
MovieClip(root).utama.resetlah();
MovieClip(root).gotoAndStop(9);
}
public function noSiCore(_arg1:MouseEvent){
MovieClip(root).utama.resetlah();
MovieClip(root).gotoAndStop(3);
}
function frame1(){
ayes.addEventListener(MouseEvent.CLICK, siScore);
ano.addEventListener(MouseEvent.CLICK, noSiCore);
}
}
}//package main_fla
Section 31
//Symbol3_41 (main_fla.Symbol3_41)
package main_fla {
import flash.display.*;
public dynamic class Symbol3_41 extends MovieClip {
public function Symbol3_41(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 32
//Symbol5_17 (main_fla.Symbol5_17)
package main_fla {
import flash.display.*;
public dynamic class Symbol5_17 extends MovieClip {
public var coveratas:MovieClip;
public function Symbol5_17(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 33
//Symbol53_23 (main_fla.Symbol53_23)
package main_fla {
import flash.display.*;
public dynamic class Symbol53_23 extends MovieClip {
public var cling:MovieClip;
public function Symbol53_23(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package main_fla
Section 34
//Symbol8_8 (main_fla.Symbol8_8)
package main_fla {
import flash.display.*;
public dynamic class Symbol8_8 extends MovieClip {
public function Symbol8_8(){
addFrameScript(29, frame30);
}
function frame30(){
stop();
}
}
}//package main_fla
Section 35
//LevelSelector (LevelSelector)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
public class LevelSelector extends MovieClip {
public var stage_ke:Number;
public var tulisan_level:TextField;
public function LevelSelector(){
gotoAndStop(1);
buttonMode = true;
this.tulisan_level.mouseEnabled = false;
addEventListener(MouseEvent.CLICK, menujuStage);
}
function menujuStage(_arg1:MouseEvent){
if (MovieClip(root).StageBoleh[this.stage_ke]){
MovieClip(root).StageSekarang = this.stage_ke;
MovieClip(root).gotoAndStop(6);
};
}
}
}//package
Section 36
//musik (musik)
package {
import flash.media.*;
public dynamic class musik extends Sound {
}
}//package
Section 37
//se (se)
package {
import flash.media.*;
public dynamic class se extends Sound {
}
}//package
Section 38
//Tile (Tile)
package {
import flash.events.*;
import flash.display.*;
public class Tile extends MovieClip {
public var kolom:int;// = 0
public var framenya:MovieClip;
public var show_jalan:MovieClip;
public var baris:int;// = 0
public var jenis:int;// = 0
public function Tile(){
jenis = 0;
baris = 0;
kolom = 0;
super();
addFrameScript(0, frame1);
addEventListener(MouseEvent.MOUSE_DOWN, diKlik, false, 0, true);
}
public function resetlah(){
if (hasEventListener(MouseEvent.MOUSE_DOWN)){
removeEventListener(MouseEvent.MOUSE_DOWN, diKlik);
};
}
function frame1(){
stop();
}
private function diKlik(_arg1:MouseEvent){
var _local2:Boolean;
var _local3:int;
var _local4:int;
_local2 = false;
_local3 = 0;
_local4 = 0;
if (!MovieClip(root).utama.sedang_cari_jalan){
if (((!((jenis == 0))) && (!((jenis == 1))))){
if (MovieClip(root).utama.simpan_klik_baris == baris){
if (MovieClip(root).utama.simpan_klik_kolom == kolom){
_local2 = true;
};
};
if (!_local2){
if (!MovieClip(root).utama.klik_satu){
MovieClip(root).utama.klik_satu = true;
MovieClip(root).utama.simpan_klik_jenis = jenis;
MovieClip(root).utama.simpan_klik_baris = baris;
MovieClip(root).utama.simpan_klik_kolom = kolom;
framenya.gotoAndStop(2);
} else {
_local3 = MovieClip(root).utama.simpan_klik_baris;
_local4 = MovieClip(root).utama.simpan_klik_kolom;
if (MovieClip(root).utama.simpan_klik_jenis == jenis){
MovieClip(root).utama.baris_kedua = baris;
MovieClip(root).utama.kolom_kedua = kolom;
MovieClip(root).utama.sedang_cari_jalan = true;
MovieClip(root).utama.cariJalan(baris, kolom, _local3, _local4);
};
MovieClip(root).utama.klik_satu = false;
MovieClip(root).utama.simpan_klik_baris = 0;
MovieClip(root).utama.simpan_klik_kolom = 0;
MovieClip(root).utama.getChildByName(((("tile_" + _local3) + "_") + _local4)).framenya.gotoAndStop(1);
};
} else {
MovieClip(root).utama.klik_satu = false;
MovieClip(root).utama.simpan_klik_baris = 0;
MovieClip(root).utama.simpan_klik_kolom = 0;
framenya.gotoAndStop(1);
};
};
};
}
}
}//package
Section 39
//YS (YS)
package {
import be.dauntless.astar.*;
import flash.geom.*;
import flash.events.*;
import be.dauntless.astar.analyzers.*;
import flash.display.*;
public class YS extends MovieClip {
public var simpan_klik_baris:int;// = 0
public var simpan_klik_kolom:int;// = 0
private var counter_lama_menghilang:int;// = 0
public var baris_kedua:int;// = 0
private var posisi_awal_stage_x:Number;// = 5
private var posisi_awal_stage_y:Number;// = 40
public var skor_sementara:uint;// = 0
private var astar:Astar;
private var lama_menghilang:int;// = 60
private var tile_hilang:int;// = 0
public var nilai_tile:Array;
public var tinggi_tile:Number;// = 35
public var kolom_kedua:int;// = 0
private var jumlah_tembok:int;// = 0
private var mulaingilang:Boolean;// = false
private var map:IMap;
private var jumlah_kolom:int;// = 18
private var jumlah_baris:int;// = 11
var jumlah_acak:int;// = 500
private var nilai_per_path:int;// = 5
public var sedang_cari_jalan:Boolean;// = false
private var total_tile:int;// = 0
public var klik_satu:Boolean;// = false
public var lebar_tile:Number;// = 35
public var simpan_klik_jenis:int;// = 0
private var jumlah_jenis_tile:Number;// = 0
private var hasil_path:Array;
public function YS(){
jumlah_baris = 11;
jumlah_kolom = 18;
posisi_awal_stage_x = 5;
posisi_awal_stage_y = 40;
jumlah_acak = 500;
lebar_tile = 35;
tinggi_tile = 35;
jumlah_jenis_tile = 0;
jumlah_tembok = 0;
nilai_tile = new Array();
total_tile = 0;
tile_hilang = 0;
klik_satu = false;
simpan_klik_jenis = 0;
simpan_klik_baris = 0;
simpan_klik_kolom = 0;
baris_kedua = 0;
kolom_kedua = 0;
hasil_path = new Array();
sedang_cari_jalan = false;
mulaingilang = false;
lama_menghilang = 60;
counter_lama_menghilang = 0;
skor_sementara = 0;
nilai_per_path = 5;
super();
}
public function mulai(){
}
public function resetlah(){
if (hasEventListener(Event.ENTER_FRAME)){
removeEventListener(Event.ENTER_FRAME, menghilangLah);
};
if (stage.hasEventListener(AstarEvent.PATH_FOUND)){
stage.removeEventListener(AstarEvent.PATH_FOUND, onPathFound);
};
if (stage.hasEventListener(AstarEvent.PATH_NOT_FOUND)){
stage.removeEventListener(AstarEvent.PATH_NOT_FOUND, onPathNotFound);
};
}
public function premulai(){
generateStage();
}
function settingAwalSkor(){
var _local1:*;
_local1 = 0;
while (_local1 < 25) {
MovieClip(MovieClip(root).getChildByName(("digit_" + _local1))).gotoAndStop(1);
_local1++;
};
}
private function onPathFound(_arg1:AstarEvent):void{
var _local2:int;
var _local3:*;
hasil_path = [];
hasil_path = _arg1.getPath().toArray();
for each (_local3 in hasil_path) {
MovieClip(root).utama.getChildByName(((("tile_" + (_local3.getPosition().y + 1)) + "_") + (_local3.getPosition().x + 1))).show_jalan.gotoAndPlay(2);
_local2++;
};
if (_local2 > 20){
MovieClip(root).skorket.isi.gotoAndStop(4);
skor_sementara = (skor_sementara + 1000);
} else {
if (_local2 > 15){
MovieClip(root).skorket.isi.gotoAndStop(3);
skor_sementara = (skor_sementara + 100);
} else {
if (_local2 > 10){
MovieClip(root).skorket.isi.gotoAndStop(2);
skor_sementara = (skor_sementara + 50);
} else {
MovieClip(root).skorket.isi.gotoAndStop(1);
skor_sementara = (skor_sementara + 10);
};
};
};
MovieClip(root).skorket.gotoAndPlay(2);
setSkor(skor_sementara);
sedang_cari_jalan = false;
MovieClip(root).utama.getChildByName(((("tile_" + baris_kedua) + "_") + kolom_kedua)).jenis = 0;
MovieClip(root).utama.nilai_tile[(baris_kedua - 1)][(kolom_kedua - 1)] = 0;
MovieClip(root).utama.getChildByName(((("tile_" + baris_kedua) + "_") + kolom_kedua)).gotoAndStop(1);
MovieClip(root).utama.getChildByName(((("tile_" + simpan_klik_baris) + "_") + simpan_klik_kolom)).jenis = 0;
MovieClip(root).utama.nilai_tile[(simpan_klik_baris - 1)][(simpan_klik_kolom - 1)] = 0;
MovieClip(root).utama.getChildByName(((("tile_" + simpan_klik_baris) + "_") + simpan_klik_kolom)).framenya.gotoAndStop(1);
MovieClip(root).utama.getChildByName(((("tile_" + simpan_klik_baris) + "_") + simpan_klik_kolom)).gotoAndStop(1);
if (MovieClip(root).suara){
MovieClip(root).SpeakerLain = MovieClip(root).cling_se.play(0, 1);
};
tile_hilang = (tile_hilang + 2);
if (tile_hilang >= total_tile){
menang();
};
}
function menang(){
mulaingilang = true;
addEventListener(Event.ENTER_FRAME, menghilangLah, false, 0, true);
}
public function cariJalan(_arg1, _arg2, _arg3, _arg4){
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:Number;
var _local10:Number;
_local6 = (_arg1 - 1);
_local5 = (_arg2 - 1);
_local8 = (_arg3 - 1);
_local7 = (_arg4 - 1);
map = new Map(nilai_tile[0].length, nilai_tile.length);
_local9 = 0;
while (_local9 < nilai_tile.length) {
_local10 = 0;
while (_local10 < nilai_tile[0].length) {
if ((((((_local9 == _local6)) && ((_local10 == _local5)))) || ((((_local9 == _local8)) && ((_local10 == _local7)))))){
map.setTile(new BasicTile(1, new Point(_local10, _local9), true));
} else {
map.setTile(new BasicTile(1, new Point(_local10, _local9), (nilai_tile[_local9][_local10] < 1)));
};
_local10++;
};
_local9++;
};
astar = new Astar();
astar.addAnalyzer(new WalkableAnalyzer());
astar.addAnalyzer(new FullClippingAnalyzer());
astar.addEventListener(AstarEvent.PATH_FOUND, onPathFound);
astar.addEventListener(AstarEvent.PATH_NOT_FOUND, onPathNotFound);
astar.getPath(new PathRequest(new Point(_local5, _local6), new Point(_local7, _local8), map));
}
private function generateStage(){
var _local1:Number;
var _local2:Number;
var _local3:int;
var _local4:int;
var _local5:Tile;
if (MovieClip(root).StageSekarang <= MovieClip(root).JumlahLevel){
if (!MovieClip(root).StageBoleh[MovieClip(root).StageSekarang]){
MovieClip(root).so.data.StageSekarang = MovieClip(root).StageSekarang;
MovieClip(root).updateLevel();
};
};
setArrayStage();
skor_sementara = MovieClip(root).SkorTotal;
setSkor(skor_sementara);
_local3 = 1;
while (_local3 <= jumlah_kolom) {
_local4 = 1;
while (_local4 <= jumlah_baris) {
if (nilai_tile[(_local4 - 1)][(_local3 - 1)] != 0){
_local1 = (posisi_awal_stage_x + (lebar_tile * (_local3 - 1)));
_local2 = (posisi_awal_stage_y + (tinggi_tile * (_local4 - 1)));
_local5 = new Tile();
_local5.name = ((("tile_" + _local4) + "_") + _local3);
_local5.x = _local1;
_local5.y = _local2;
_local5.baris = _local4;
_local5.kolom = _local3;
_local5.jenis = nilai_tile[(_local4 - 1)][(_local3 - 1)];
_local5.gotoAndStop((_local5.jenis + 1));
MovieClip(root).utama.addChild(_local5);
};
_local4++;
};
_local3++;
};
}
function menghilangLah(_arg1:Event){
counter_lama_menghilang++;
MovieClip(root).utama.alpha = (1 - (counter_lama_menghilang / lama_menghilang));
MovieClip(root).bg_utama.coveratas.alpha = (1 - (counter_lama_menghilang / lama_menghilang));
if (counter_lama_menghilang >= lama_menghilang){
MovieClip(root).StageSekarang++;
resetlah();
simpanSkor();
mulaingilang = false;
MovieClip(root).utama.visible = false;
MovieClip(root).bg_utama.coveratas.visible = false;
MovieClip(root).toret.visible = false;
MovieClip(root).tombol_main_menu.visible = false;
MovieClip(root).tulsta.visible = false;
MovieClip(root).skiper.visible = true;
MovieClip(root).spolo.visible = false;
};
}
private function onPathNotFound(_arg1:AstarEvent):void{
sedang_cari_jalan = false;
}
private function setArrayStage(){
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
nilai_tile = [];
switch (MovieClip(root).StageSekarang){
case 1:
jumlah_jenis_tile = (7 + 0.5);
jumlah_tembok = 0;
break;
case 2:
jumlah_jenis_tile = (9 + 0.5);
jumlah_tembok = 2;
break;
case 3:
jumlah_jenis_tile = (10 + 0.5);
jumlah_tembok = 3;
break;
case 4:
jumlah_jenis_tile = (12 + 0.5);
jumlah_tembok = 4;
break;
case 5:
jumlah_jenis_tile = (13 + 0.5);
jumlah_tembok = 5;
break;
case 6:
jumlah_jenis_tile = (15 + 0.5);
jumlah_tembok = 7;
break;
case 7:
jumlah_jenis_tile = (16 + 0.5);
jumlah_tembok = 8;
break;
case 8:
jumlah_jenis_tile = (18 + 0.5);
jumlah_tembok = 10;
break;
};
nilai_tile = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
_local1 = 1;
_local2 = 0;
_local1 = acak(2, jumlah_jenis_tile);
_local3 = 1;
while (_local3 <= jumlah_kolom) {
_local10 = 1;
while (_local10 <= jumlah_baris) {
nilai_tile[(_local10 - 1)][(_local3 - 1)] = _local1;
_local2++;
if (_local2 >= 2){
_local1 = acak(2, jumlah_jenis_tile);
_local2 = 0;
};
_local10++;
};
_local3++;
};
_local4 = 0;
_local3 = 1;
while (_local3 <= jumlah_kolom) {
_local10 = 1;
while (_local10 <= jumlah_baris) {
if (_local4 < (jumlah_tembok * 2)){
_local4++;
nilai_tile[(_local10 - 1)][(_local3 - 1)] = 1;
};
_local10++;
};
_local3++;
};
total_tile = ((jumlah_kolom * jumlah_baris) - (jumlah_tembok * 2));
_local5 = 0;
_local6 = 0;
_local7 = 0;
_local8 = 0;
_local3 = 0;
while (_local3 < jumlah_acak) {
_local5 = acak(1, jumlah_kolom);
_local6 = acak(1, jumlah_baris);
_local7 = acak(1, jumlah_kolom);
_local8 = acak(1, jumlah_baris);
_local9 = nilai_tile[(_local6 - 1)][(_local5 - 1)];
nilai_tile[(_local6 - 1)][(_local5 - 1)] = nilai_tile[(_local8 - 1)][(_local7 - 1)];
nilai_tile[(_local8 - 1)][(_local7 - 1)] = _local9;
_local3++;
};
}
function setSkor(_arg1:Number){
var _local2:*;
settingAwalSkor();
_local2 = 0;
while (_local2 < int(String(_arg1).length)) {
MovieClip(MovieClip(root).getChildByName(("digit_" + ((int(String(_arg1).length) - 1) - _local2)))).gotoAndStop((int(String(_arg1).charAt(_local2)) + 2));
MovieClip(MovieClip(root).getChildByName(("digit_" + ((int(String(_arg1).length) - 1) - _local2)))).cling.gotoAndPlay(2);
_local2++;
};
}
public function simpanSkor(){
MovieClip(root).SkorTotal = skor_sementara;
}
function acak(_arg1, _arg2){
return (((Math.floor((Math.random() * ((1 + (_arg2 * 10)) - (_arg1 * 10)))) + (_arg1 * 10)) / 10));
}
}
}//package