mouse 'n' stuff

by wh0
The native cursor fast. (gray ring)
Even when the stage frame rate is low, we can have the Flash Player redraw after certain events. (MOUSE_MOVE moves black dot and requests redraw)
The text value only changes on ENTER_FRAME events.

For me, the dot is a little bit behind the ring.
♥2 | Line 49 | Modified 2011-07-11 07:30:36 | MIT License
play

ActionScript3 source code

/**
 * Copyright wh0 ( http://wonderfl.net/user/wh0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/saZ0
 */

package {
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.ui.*;
    public class FlashTest extends Sprite {
        
        private var a:Shape;
        private var b:Shape;
        
        public function FlashTest() {
            // the dot: moves on ENTER_FRAME event
            a = new Shape();
            a.graphics.beginFill(0x000000);
            a.graphics.drawCircle(0, 0, 6);
            addChild(a);
            stage.addEventListener(Event.ENTER_FRAME, frame);
            
            // the small ring: moves with the mouse
            b = new Shape();
            b.graphics.lineStyle(4, 0x000000);
            b.graphics.drawCircle(0, 0, 8);
            addChild(b);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, move);
            stage.addEventListener(Event.MOUSE_LEAVE, leave);
            
            // the large ring: native cursor
            var bd:BitmapData = new BitmapData(32, 32, true, 0x00000000);
            var sh:Shape = new Shape();
            sh.graphics.lineStyle(4, 0x000000);
            sh.graphics.drawCircle(16, 16, 12);
            bd.draw(sh);
            var mcd:MouseCursorData = new MouseCursorData();
            mcd.data = new Vector.<BitmapData>(1);
            mcd.data[0] = bd;
            mcd.hotSpot = new Point(16, 16);
            Mouse.registerCursor('ring', mcd);
            Mouse.cursor = 'ring';
        }
        
        private function frame(e:Event):void {
            a.x = mouseX;
            a.y = mouseY;
        }
        
        private function leave(e:Event):void {
            a.visible = false;
            b.visible = false;
            // can't updateAfterEvent(); dot lingers for up to a second
        }
        
        private function move(e:MouseEvent):void {
            a.visible = true;
            b.visible = true;
            b.x = e.stageX;
            b.y = e.stageY;
            e.updateAfterEvent(); // request redraw
        }
        
    }
}

Forked