这几天突然发现传统用cursorManager.setCursor(...);设置光标样式会有顿卡的感觉。
现在可以利用BitmapData实现此功能,并且一点不卡,性能明显要好得多,不解释,上源码,你懂的!
Cursor类:
package
{import flash.display.Bitmap;import flash.display.BitmapData;import flash.display.Loader;import flash.events.Event;import flash.net.URLRequest;import flash.ui.Mouse;import flash.ui.MouseCursorData;public class Cursor{private var _cursor:Array;private var loader:Loader;public function Cursor(cursor:Array){this.cursor = cursor;}public function get cursor():Array{return _cursor;}public function set cursor(value:Array):void{_cursor = value;if(_cursor && _cursor.length == 2){loader = new Loader();loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);loader.load(new URLRequest(_cursor[1]));}}protected function onComplete(event:Event):void{var cursorData : Vector.
}
调用:传入一个数组,索引0位置为cursor名称,索引1位置为cursor图片路径
new Cursor(["newCursor",Config.CURSOR_BLUE]);