home *** CD-ROM | disk | FTP | other *** search
- package classes.basic.Mouse
- {
- import classes.basic.Events.TFEvent;
- import classes.basic.MovieClip.TFMovieClip;
- import classes.basic.Sound.TFSound;
- import flash.display.DisplayObject;
- import flash.display.MovieClip;
- import flash.events.MouseEvent;
- import flash.geom.Point;
- import flash.ui.Mouse;
- import flash.utils.getDefinitionByName;
-
- public class TFMouseWeb
- {
-
-
- private var bRegistered:Boolean;
-
- private var scene:MovieClip;
-
- private var pCoord:Point;
-
- private var arEvents:Array;
-
- protected var mcMouse:MovieClip;
-
- private var fxMouseDown:TFSound;
-
- public function TFMouseWeb(param1:MovieClip)
- {
- super();
- scene = param1;
- bRegistered = false;
- arEvents = new Array();
- arEvents[TFEvent.EVENT_MOUSEMOVE] = new Array();
- pCoord = new Point(0,0);
- scene.stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove,false,0,true);
- scene.stage.addEventListener(MouseEvent.CLICK,onMouseClick,false,0,true);
- scene.stage.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown,false,0,true);
- }
-
- private function dispatchEvent(param1:TFEvent) : *
- {
- var _loc2_:Array = null;
- var _loc3_:* = undefined;
- _loc2_ = arEvents[param1.event];
- for(_loc3_ in _loc2_)
- {
- if(_loc2_[_loc3_](param1) == true)
- {
- break;
- }
- }
- }
-
- public function registerEvent(param1:String, param2:Function) : Boolean
- {
- arEvents[param1].push(param2);
- return true;
- }
-
- protected function onMouseDown(param1:MouseEvent) : void
- {
- if(bRegistered)
- {
- if(this.fxMouseDown != null)
- {
- this.fxMouseDown.play();
- }
- }
- param1.updateAfterEvent();
- }
-
- public function removeImage(param1:String, param2:String) : *
- {
- var _loc3_:MovieClip = null;
- if(param2 == null || param2 == "")
- {
- _loc3_ = mcMouse;
- }
- else
- {
- _loc3_ = MovieClip(mcMouse.getChildByName(param2));
- }
- _loc3_.removeChild(_loc3_.getChildByName(param1));
- }
-
- public function showIcon(param1:String) : *
- {
- this.mcMouse.gotoAndStop(param1);
- }
-
- protected function onMouseClick(param1:MouseEvent) : void
- {
- if(bRegistered)
- {
- if(mcMouse.splash != null)
- {
- mcMouse.splash.gotoAndPlay(2);
- }
- }
- param1.updateAfterEvent();
- }
-
- public function register() : *
- {
- var _loc1_:Class = null;
- if(bRegistered)
- {
- return;
- }
- Mouse.hide();
- _loc1_ = getDefinitionByName("mouseCursor") as Class;
- mcMouse = new _loc1_();
- scene.stage.addChild(mcMouse);
- TFMovieClip.setMouseEnabled(mcMouse,false);
- bRegistered = true;
- }
-
- public function attachImage(param1:String, param2:MovieClip, param3:String) : *
- {
- var mcTarget:MovieClip = null;
- var p_frame:String = param1;
- var p_mc:MovieClip = param2;
- var p_target:String = param3;
- mcMouse.gotoAndStop(p_frame);
- TFMovieClip.addLabelScript(mcMouse,p_frame,function():*
- {
- TFMovieClip.addLabelScript(mcMouse,p_frame,null);
- if(p_target == null || p_target == "")
- {
- mcTarget = mcMouse;
- }
- else
- {
- mcTarget = MovieClip(mcMouse.getChildByName(p_target));
- }
- mcTarget.addChild(p_mc);
- TFMovieClip.setMouseEnabled(mcTarget,false);
- });
- }
-
- protected function onMouseMove(param1:MouseEvent) : void
- {
- if(bRegistered)
- {
- mcMouse.x = pCoord.x = scene.stage.mouseX;
- mcMouse.y = pCoord.y = scene.stage.mouseY;
- dispatchEvent(new TFEvent(TFEvent.EVENT_MOUSEMOVE,pCoord as Object));
- }
- param1.updateAfterEvent();
- }
-
- public function setFxMouseDown(param1:TFSound) : *
- {
- this.fxMouseDown = param1;
- }
-
- public function unregister() : *
- {
- if(!bRegistered)
- {
- return;
- }
- Mouse.show();
- scene.mouseDummy.removeChild(DisplayObject(mcMouse));
- bRegistered = false;
- }
-
- public function unregisterEvent(param1:String, param2:Function) : Boolean
- {
- var _loc3_:Array = null;
- var _loc4_:Number = NaN;
- _loc3_ = arEvents[param1];
- _loc4_ = 0;
- while(_loc4_ < _loc3_.length)
- {
- if(_loc3_[_loc4_] == param2)
- {
- _loc3_.splice(_loc4_,1);
- return true;
- }
- _loc4_++;
- }
- return false;
- }
- }
- }
-