Using Flex's default cursors

So I made my own component, and I wanted the default move cursor that Flex has built in to appear on the mouse over of my component. I thought this would be an easy task - oh how wrong I was.

An hour of researching later I was no further ahead, besides discovering that mx.skins.cursor.moveCursor was in fact a style and the image was in Assets.css (from this helpful webpage here: http://www.loscavio.com/downloads/blog/flex3_css_list/flex3_css_list.htm). It occurred to me that I know how to get a value out of a CSS file, and therein lied the solution.


[Bindable]
public var myCursor:Class;

//Called on creation complete
public function complete():void
{
myCursor = mx.styles.StyleManager.getStyleDeclaration('DragManager').getStyle('moveCursor');
}

//Called on mouseover of the component
protected function mouseOverWindow(evt:MouseEvent):void
{
CursorManager.setCursor(myCursor);
}

//Called on mouseout of the component
protected function mouseOutWindow(evt:MouseEvent):void
{
CursorManager.removeCursor(CursorManager.currentCursorID);
}

Comments

arelenas said…
Thanks Ang, you saved me a lot of time! This was exactly what I was looking for.

Popular posts from this blog

Flex Advanced Data Grid collapses on refresh

Add and remove lineseries - Flex LineChart