自己画图更换鼠标显示形状

CircleCursor类
package
{
	import flash.display.Sprite;
	import flash.geom.Point;

	public class CircleCursor extends Sprite 
		
	{ 
		//画故障选择
	//	[Bindable]private var lp:Point = new Point();
		//[Bindable]private var rp:Point = new Point();
		
		public function CircleCursor(x:int,y:int) 
			
		{ 
//			graphics.lineStyle(3,0xff0000);
//			graphics.moveTo(50,50);
//			graphics.lineTo(100,50);
//			graphics.moveTo(75,25);
//			graphics.lineTo(75,75);

			graphics.clear();
			graphics.lineStyle(3,0xff0000);
			graphics.moveTo(x,y+10);
			graphics.lineTo(x,y-10);
			graphics.moveTo(x-10,y);
			graphics.lineTo(x+10,y);
			super(); 
			
		} 
		
		
		
	} 

}


主体
<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"    
			   xmlns:s="library://ns.adobe.com/flex/spark"    
			   xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" xmlns:mx1="library://ns.adobe.com/flex/mx"> 
	<s:layout> 
		<s:BasicLayout/> 
	</s:layout> 

	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.core.BitmapAsset;    
			// 自定义的鼠标元素   
			var myCursor:Sprite = new Sprite(); 
			private var bn:Boolean = true;
			protected function button1_clickHandler():void   
			{   
				Alert.show("123");
			}  
			// 监听函数   
			protected function mousemoveHandler(event:MouseEvent):void   
			{   
				myCursor.x =event.stageX;   
				myCursor.y = event.stageY;   
			}  
			var canVol:CircleCursor=new CircleCursor(0,0);

			protected function panel1_mouseOverHandler(event:MouseEvent):void
			{
				// 把图片设置到自己的鼠标元素上去   
				if(canVol!=null){
				canVol.graphics.clear();
				canVol = new CircleCursor(event.stageX,event.stageY);
				}
				myCursor.addChild(canVol);   
				myCursor.addEventListener(MouseEvent.CLICK,panel1_clickHandler);
				stage.addChild(myCursor); 
				Mouse.hide();
			}
	

			protected function panel1_clickHandler(event:MouseEvent):void
			{
				Alert.show(event.stageX.toString()+"-------"+event.stageY.toString());
			}

		]]>
	</fx:Script>
	
	<fx:Declarations> 
		<!-- Place non-visual elements (e.g., services, value objects) here --> 
	</fx:Declarations> 
	<s:Button x="274" y="177" label="按钮111" click="button1_clickHandler()" />
	<s:Panel mouseOver="panel1_mouseOverHandler(event)" width="100%" height="100%" mouseMove="panel1_mouseOverHandler(event)" >
		<s:Button x="274" y="177" label="按钮" click="button1_clickHandler()"  />
	</s:Panel>
</s:Application>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值