home *** CD-ROM | disk | FTP | other *** search
- package com.mochi
- {
- import flash.display.Sprite;
- import flash.text.TextField;
- import flash.text.TextFormat;
- import flash.text.TextFormatAlign;
-
- public dynamic class TextScoreTable extends Sprite
- {
-
-
- private var _max_scores:Number;
-
- private var _status:TextField;
-
- private var _names:TextField;
-
- public var title:TextField;
-
- private var _scores:TextField;
-
- private var _dates:TextField;
-
- private var _ranks:TextField;
-
- public function TextScoreTable(param1:Number = 10)
- {
- super();
- _max_scores = param1;
- }
-
- public static function commafy(param1:Number) : String
- {
- var _loc2_:Number = NaN;
- var _loc3_:String = null;
- var _loc4_:Array = null;
- _loc2_ = param1;
- if(_loc2_ < 0)
- {
- _loc2_ *= 1;
- }
- _loc3_ = Math.floor(_loc2_).toString();
- _loc4_ = [];
- while(_loc3_.length > 3)
- {
- _loc4_.unshift(_loc3_.slice(_loc3_.length - 3,_loc3_.length));
- _loc3_ = _loc3_.slice(0,_loc3_.length - 3);
- }
- _loc4_.unshift(_loc3_);
- return _loc4_.join(",");
- }
-
- public function init() : void
- {
- title = new_tf("title");
- title.x = 77;
- title.width = 199;
- title.text = "High Scores";
- _status = new_tf("center");
- _status.width = width;
- _status.y = 200;
- _status.width = 360;
- _ranks = new_tf("left");
- _ranks.x = 20;
- _ranks.y = 60;
- _ranks.width = 30;
- _ranks.height = 184;
- _names = new_tf("left");
- _names.x = 45;
- _names.y = 60;
- _names.width = 278;
- _names.height = 184;
- _dates = new_tf("right");
- _dates.x = 159;
- _dates.y = 60;
- _dates.width = 84;
- _dates.height = 184;
- _scores = new_tf("right");
- _scores.x = 230;
- _scores.y = 60;
- _scores.width = 103;
- _scores.height = 184;
- reset();
- }
-
- public function msecToDateString(param1:Number) : String
- {
- var _loc2_:Date = null;
- _loc2_ = new Date(param1);
- return [_loc2_.getFullYear(),1 + _loc2_.getMonth(),_loc2_.getDate()].join("-");
- }
-
- public function reset(param1:String = "") : void
- {
- _ranks.text = "";
- _names.text = "";
- _scores.text = "";
- _dates.text = "";
- _status.text = param1;
- }
-
- public function new_tf(param1:String) : TextField
- {
- var _loc2_:TextField = null;
- _loc2_ = new TextField();
- _loc2_.defaultTextFormat = scoreTextFormat(param1);
- _loc2_.selectable = false;
- addChild(_loc2_);
- return _loc2_;
- }
-
- private function scoreTextFormat(param1:String) : TextFormat
- {
- var _loc2_:TextFormat = null;
- _loc2_ = new TextFormat();
- _loc2_.font = "_sans";
- _loc2_.color = 13421772;
- _loc2_.size = 14;
- if(param1 == "left")
- {
- _loc2_.align = TextFormatAlign.LEFT;
- }
- else if(param1 == "right")
- {
- _loc2_.align = TextFormatAlign.RIGHT;
- }
- else if(param1 == "center")
- {
- _loc2_.align = TextFormatAlign.CENTER;
- }
- else
- {
- if(param1 != "title")
- {
- throw new Error("Invalid text format " + param1);
- }
- _loc2_.align = TextFormatAlign.CENTER;
- _loc2_.color = 16777215;
- _loc2_.size = 32;
- }
- return _loc2_;
- }
-
- public function gotScores(param1:Array, param2:Number = -1) : void
- {
- var _loc3_:Number = NaN;
- var _loc4_:String = null;
- var _loc5_:String = null;
- var _loc6_:String = null;
- var _loc7_:String = null;
- var _loc8_:Number = NaN;
- var _loc9_:Array = null;
- var _loc10_:* = null;
- var _loc11_:String = null;
- var _loc12_:String = null;
- var _loc13_:String = null;
- reset();
- title.text = "High Scores";
- _loc3_ = Math.min(_max_scores,param1.length);
- if(_loc3_ == 0)
- {
- this.mc.status_text = "No high scores yet!";
- return;
- }
- _loc4_ = "";
- _loc5_ = "";
- _loc6_ = "";
- _loc7_ = "";
- _loc8_ = 0;
- while(_loc8_ < _loc3_)
- {
- _loc9_ = param1[_loc8_];
- _loc10_ = _loc8_ + 1 + ".";
- if(_loc8_ == param2)
- {
- _loc10_ = "*" + _loc10_;
- }
- _loc11_ = String(_loc9_[0]);
- _loc12_ = commafy(_loc9_[1]);
- _loc13_ = msecToDateString(_loc9_[2]);
- _loc4_ += _loc10_ + "\n";
- _loc5_ += _loc11_ + "\n";
- _loc6_ += _loc12_ + "\n";
- _loc7_ += _loc13_ + "\n";
- _loc8_++;
- }
- _ranks.text = _loc4_;
- _names.text = _loc5_;
- _scores.text = _loc6_;
- _dates.text = _loc7_;
- }
- }
- }
-