home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 145
/
MOBICLIC145.ISO
/
pc
/
DATA
/
DSS145
/
DSS145_10
/
DSS145_10.swf
/
scripts
/
Cursor.as
< prev
next >
Wrap
Text File
|
2012-07-18
|
3KB
|
125 lines
package
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.ui.Mouse;
import flash.utils.Timer;
public class Cursor
{
private var _parent:DisplayObjectContainer;
private var _cursorLib:MovieClip;
private var _cursorName:String = "fleche";
private var _timer:Timer;
private var _lock:Boolean = false;
public function Cursor(param1:MovieClip, param2:DisplayObjectContainer)
{
super();
this._cursorLib = param1;
this._cursorLib.mouseChildren = false;
this._cursorLib.mouseEnabled = false;
this._cursorLib.enabled = false;
this._parent = param2;
this._timer = new Timer(1,0);
this._timer.addEventListener(TimerEvent.TIMER,this.timerHandler);
}
public function set cursor(param1:String) : void
{
this._cursorName = param1;
switch(param1)
{
case "fleche":
case "doigt":
if(this._cursorLib.parent === this._parent)
{
this._cursorLib.parent.removeChild(this._cursorLib);
}
this._timer.stop();
Mouse.show();
break;
default:
Mouse.hide();
this._cursorLib.gotoAndStop(this._cursorName);
if(this._cursorLib.parent !== this._parent)
{
this._parent.addChild(this._cursorLib);
}
if(this._lock == false)
{
this._timer.start();
}
}
}
private function timerHandler(param1:TimerEvent) : void
{
this._cursorLib.x = this._cursorLib.stage.mouseX;
this._cursorLib.y = this._cursorLib.stage.mouseY;
param1.updateAfterEvent();
}
public function destroy() : void
{
this._timer.removeEventListener(TimerEvent.TIMER,this.timerHandler);
}
public function get x() : Number
{
return this._cursorLib.x;
}
public function set x(param1:Number) : void
{
this._cursorLib.x = param1;
}
public function get y() : Number
{
return this._cursorLib.y;
}
public function set y(param1:Number) : void
{
this._cursorLib.y = param1;
}
public function get lock() : Boolean
{
return this._lock;
}
public function set lock(param1:Boolean) : void
{
if(this._lock == param1)
{
return;
}
this._lock = param1;
switch(this._cursorName)
{
case "fleche":
case "doigt":
break;
default:
if(this._lock == true)
{
this._timer.stop();
}
else
{
this._timer.start();
}
}
}
}
}