forked from: ネイティブマウスカーソルのテスト
// forked from undo's ネイティブマウスカーソルのテスト
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.ui.Mouse;
import flash.ui.MouseCursor;
import flash.ui.MouseCursorData;
import com.bit101.components.PushButton;
[SWF(width="465",height="465",frameRate="30",backgroundColor="0xffffff")]
public class ASTest extends Sprite
{
private var btn0:PushButton;
private var btn1:PushButton;
private var btn2:PushButton;
private var btn3:PushButton;
private var btn4:PushButton;
private var btn5:PushButton;
public function ASTest()
{
init();
}
private function init():void
{
var cursor:Sprite = new Sprite();
cursor.graphics.lineStyle(1,0);
cursor.graphics.moveTo(16,0);
cursor.graphics.lineTo(16,32);
cursor.graphics.moveTo(0,16);
cursor.graphics.lineTo(32,16);
var vector:Vector.<BitmapData> = new Vector.<BitmapData>();
vector[0] = new BitmapData(32,32,true,0x00000000);
vector[0].draw(cursor);
var cursorData:MouseCursorData = new MouseCursorData();
cursorData.hotSpot = new Point(16,16);
cursorData.data = vector;
Mouse.registerCursor('myCursor', cursorData);
btn0 = new PushButton(this,0,0,"MyCursor");
btn1 = new PushButton(this,0,20,"MouseCursor.AUTO");
btn2 = new PushButton(this,0,40,"MouseCursor.ARROW");
btn3 = new PushButton(this,0,60,"MouseCursor.BUTTON");
btn4 = new PushButton(this,0,80,"MouseCursor.HAND");
btn5 = new PushButton(this,0,100,"MouseCursor.IBEAM");
btn0.addEventListener(MouseEvent.CLICK, onClick);
btn1.addEventListener(MouseEvent.CLICK, onClick);
btn2.addEventListener(MouseEvent.CLICK, onClick);
btn3.addEventListener(MouseEvent.CLICK, onClick);
btn4.addEventListener(MouseEvent.CLICK, onClick);
btn5.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(evt:MouseEvent):void
{
switch(evt.target)
{
case btn0:
Mouse.cursor = 'myCursor';
break;
case btn1:
Mouse.cursor = MouseCursor.AUTO;
break;
case btn2:
Mouse.cursor = MouseCursor.ARROW;
break;
case btn3:
Mouse.cursor = MouseCursor.BUTTON;
break;
case btn4:
Mouse.cursor = MouseCursor.HAND;
break;
case btn5:
Mouse.cursor = MouseCursor.IBEAM;
break;
}
}
}
}