最近项目很少繁忙啊,也很少写文章了。写作工程不能放下啊,所以今天叮嘱自己写下遇到的困难。
Flex强制改变鼠标的样式,有很多种方式和方法。
1.用Flex sdk自定义的方式修改
<mx:Label useHandCursor="true" />
flex 4以上的版本请用下面的方式
<mx:Label useHandCursor="true" buttonMode="true" mouseChildren="false" />
上面就该成小手的样式。
2.用CursorManger来修改
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import flash.events.MouseEvent ; import mx.managers.CursorManager; private var cursorId:Number=0; [Embed(source="images/A.JPG")] private var A_Cursor:Class; [Embed(source="images/B.JPG")] private var B_Cursor:Class; private function onMouseOut(event:MouseEvent):void { CursorManager.removeCursor(cursorId); cursorId=CursorManager.setCursor(B_Cursor); } private function onMouseOver(event:MouseEvent):void { CursorManager.removeCursor(cursorId); cursorId=CursorManager.setCursor(A_Cursor); } ]]> </mx:Script> <mx:Button id="button1" x="172" y="156" label="Show" mouseOver="onMouseOver(event)" mouseOut="onMouseOut(event)" /> </mx:Application>
主要是利用事件的处理来添加和删除鼠标样式
下面有些默认的鼠标样式
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" fontSize="12"> <mx:Script> <![CDATA[ import mx.managers.CursorManager; private function setCursor():void { CursorManager.removeAllCursors(); } private function setCursorBusy():void { CursorManager.setBusyCursor(); } private function canCursorBusy():void { CursorManager.removeBusyCursor(); } ]]> </mx:Script> <mx:Button label="忙碌光标" click="setCursorBusy()"/> <mx:Button label="取消忙碌光标" click="canCursorBusy()"/> <mx:Button label="恢复正常光标" click="setCursor()"/> </mx:Application>
如果有什么问题请和我联系。希望能帮助你