Link와 같은 hand cursor 로 형태를 변경해야 할 경우가 있다.
그럴 경우
[Embed(source="/image/handCursor.png")] private var hadnCursor:Class; //설정 //-9,-9 를 주는 이유는, mouse좌표에서 그정도 pix를 움직여야 이미지가 중심에 온다 CursorUtils.changeCursor(hadnCursor, -9, -9); //해제 CursorUtils.changeCursor(null, 0, 0);
SOURCE CODE :
package sjd.utils
{
import mx.managers.CursorManager;
import mx.managers.CursorManagerPriority;
/**
* @class CursorUtil
* @brief Set the cursor image
* @author Jove
* @version 1.2
*/
public class CursorUtils{
private static var currentType:Class = null;
/**
* Remove the current cursor and set an image.
* @param type The image class
* @param xOffset The xOffset of the cursorimage
* @param yOffset The yOffset of the cursor image
*/
public static function changeCursor(type:Class, xOffset:Number = 0, yOffset:Number = 0):void{
if(currentType != type){
currentType = type;
CursorManager.removeCursor(CursorManager.currentCursorID);
if(type != null){
CursorManager.setCursor(type, CursorManagerPriority.MEDIUM, xOffset, yOffset);
}
}
}
}
}
/**
* Remove the current cursor and set an image.
* @param type The image class
* @param xOffset The xOffset of the cursorimage
* @param yOffset The yOffset of the cursor image
*/
public static function changeCursor(type:Class, xOffset:Number = 0, yOffset:Number = 0):void{
if(currentType != type){
currentType = type;
CursorManager.removeCursor(CursorManager.currentCursorID);
if(type != null){
CursorManager.setCursor(type, CursorManagerPriority.MEDIUM, xOffset, yOffset);
}
}
}
}
}