Thursday, January 28, 2010

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: It occurred to me that I know how to get a value out of a CSS file, and therein lied the solution.

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

//Called on mouseout of the component
protected function mouseOutWindow(evt:MouseEvent):void

1 comment:

arelenas said...

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