tags:

views:

353

answers:

2

In an online mapping application I'm doing in Flex 3 I need a cursor for certain operations that has XOR coloring with the background.

i.e. it is always the "negative" color of whatever pixels it stands above off (white on black, red on green, etc.).

Can this be done with Flex? (Can I roll my own programmatic cursor?)

+1  A: 

Sure, you can have your own cursor: http://www.switchonthecode.com/tutorials/flex-custom-cursor-tutorial

Hope that helps!

yn2
+2  A: 

Take a look at displayObject.blendMode property: http://livedocs.adobe.com/flex/3/langref/flash/display/BlendMode.html#INVERT

Use a custom cursor with that property set to BlendMode.INVERT

Update: here is the solution

Cursor class:

package test
{
import flash.display.BlendMode;
import flash.display.Graphics;
import flash.display.Sprite;

public class InvertCursor extends Sprite
{
    public function InvertCursor()
    {
        super();
        draw();
        blendMode = BlendMode.INVERT;
    }

    public function draw():void {
        var g:Graphics = graphics;
        g.clear();
        g.beginFill(0);
        g.lineStyle(0);
        g.drawCircle(0, 0, 10);
        g.endFill();
    }

}
}

Usage:

import mx.managers.CursorManager;
import test.InvertCursor;

private function setInvertCursor():void  {
    CursorManager.setCursor(InvertCursor);
}
Hrundik
I'm afraid this is not clear: the only relevant parameter I have when setting a custom cursor is the class that represents the cursor's image (and I only get an ID from CursorManager). How/where do I set the blend mode?
Dan
Updated my answer to include the solution, not just the hint.
Hrundik