home *** CD-ROM | disk | FTP | other *** search
- package game
- {
- import flash.display.MovieClip;
- import flash.events.MouseEvent;
- import flash.geom.Rectangle;
- import flash.text.TextField;
-
- [Embed(source="/_assets/assets.swf", symbol="game.FielsField")]
- public class FielsField extends MovieClip
- {
-
-
- public var f10:MovieClip;
-
- public var f11:MovieClip;
-
- public var f13:MovieClip;
-
- public var f14:MovieClip;
-
- private var scrollBar:Button;
-
- public var f12:MovieClip;
-
- public var BG:MovieClip;
-
- public var sc:scrollbar;
-
- public var txt:TextField;
-
- public var files:Array;
-
- public var currentOpened:MovieClip;
-
- public var f6:MovieClip;
-
- public var f7:MovieClip;
-
- public var f4:MovieClip;
-
- public var f8:MovieClip;
-
- public var f1:MovieClip;
-
- public var f3:MovieClip;
-
- public var f5:MovieClip;
-
- public var f9:MovieClip;
-
- private var txtHeight:Number = 0;
-
- public var f2:MovieClip;
-
- public var _txt:TextField;
-
- public function FielsField()
- {
- txtHeight = 0;
- super();
- _txt = getChildByName("txt") as TextField;
- scrollBar = getChildByName("sc") as Button;
- scrollBar.addEventListener(MouseEvent.MOUSE_DOWN,dragBar,false,0,true);
- initFiles();
- }
-
- private function showFile(param1:MouseEvent) : void
- {
- var _loc2_:MovieClip = null;
- var _loc3_:uint = 0;
- var _loc4_:* = undefined;
- _loc2_ = param1.currentTarget as MovieClip;
- if(_loc2_.name != currentOpened.name)
- {
- currentOpened.gotoAndStop("full");
- currentOpened = param1.currentTarget as MovieClip;
- _loc3_ = Number(currentOpened.name.split("f")[1]);
- currentOpened.gotoAndStop("open");
- for each(_loc4_ in files)
- {
- if(Number(_loc4_) == _loc3_)
- {
- _txt.text = Model.getInstance().getMessage(_loc3_);
- resetScrollBar();
- }
- }
- }
- }
-
- private function dragBar(param1:MouseEvent) : void
- {
- scrollBar.startDrag(false,new Rectangle(623.5,208,0,105.5));
- }
-
- public function saveBook() : void
- {
- var _loc1_:Array = null;
- var _loc2_:* = undefined;
- _loc1_ = new Array();
- for each(_loc2_ in files)
- {
- _loc1_.push(_loc2_);
- }
- Model.getInstance().currentData.ateBooks = _loc1_;
- }
-
- public function addNewFile(param1:*, param2:Boolean = false) : void
- {
- var _loc3_:MovieClip = null;
- files.push(param1.data);
- if(currentOpened != null)
- {
- currentOpened.gotoAndStop("full");
- }
- _loc3_ = this.getChildByName("f" + param1.data) as MovieClip;
- _loc3_.gotoAndStop("open");
- currentOpened = _loc3_;
- _txt.text = Model.getInstance().getMessage(int(param1.data));
- resetScrollBar();
- _loc3_.addEventListener(MouseEvent.CLICK,showFile,false,0,true);
- }
-
- private function initFiles() : void
- {
- var _loc1_:Array = null;
- var _loc2_:Array = null;
- var _loc3_:* = undefined;
- currentOpened = null;
- files = new Array();
- _loc1_ = Model.getInstance().currentData.ateBooks;
- if(Model.cData == null)
- {
- _loc2_ = new Array();
- }
- else
- {
- _loc2_ = Model.cData.ateBooks;
- }
- if(_loc1_ == null)
- {
- if(_loc2_ != null)
- {
- _loc1_ = _loc2_;
- }
- else
- {
- _loc1_ = new Array();
- }
- }
- else if(_loc2_ != null && _loc2_.length > _loc1_.length)
- {
- _loc1_ = _loc2_;
- }
- Model.books = files;
- for each(_loc3_ in _loc1_)
- {
- addNewFile({"data":_loc3_},true);
- }
- }
-
- public function reset() : void
- {
- var i:int = 0;
- var cld:MovieClip = null;
- _txt.text = "";
- resetScrollBar();
- i = 1;
- while(i <= 14)
- {
- cld = this.getChildByName("f" + i) as MovieClip;
- cld.gotoAndStop("empty");
- try
- {
- cld.removeEventListener(MouseEvent.CLICK,showFile);
- }
- catch(e:Error)
- {
- }
- i++;
- }
- initFiles();
- }
-
- private function resetScrollBar() : void
- {
- _txt.y = 201;
- txtHeight = _txt.textHeight + 25;
- scrollBar.x = 623.5;
- scrollBar.y = 208;
- }
-
- public function setTxt() : void
- {
- if(txtHeight < 115)
- {
- return;
- }
- _txt.y = 201 - (txtHeight - 115) / 115 * (scrollBar.y - 208);
- }
-
- public function _stopDrag() : void
- {
- scrollBar.stopDrag();
- }
- }
- }
-