| Package | flash.ui | 
| Class | public final class MouseCursorData | 
| Inheritance | MouseCursorData    Object | 
| Language Version: | ActionScript 3.0 | 
| Runtime Versions: | Flash Player 10.2, AIR 2.6 | 
To display the cursor, use the Mouse.registerCursor() function. To return
	control of the cursor image to the operating system, call Mouse.unregisterCursor().
	Call Mouse.supportsNativeCursor to test whether native cursors are supported on the
	current computer.
The maximum cursor size is 32x32 pixels.Transparency is supported on most operating systems.
A native mouse cursor is implemented directly through the operating system cursor mechanism 
	and is a more efficient means for displaying a custom cursor image than using a display object.
	You can animate the cursor by supplying more than one image in the data property
	and setting the frame rate. 
The cursor is only displayed within the bounds of the stage. Outside the stage, control of the cursor image returns to the operating system
Learn more
Related API Elements
| Property | Defined By | ||
|---|---|---|---|
![]()  | constructor : Object 
	 A reference to the class object or constructor function for a given object instance.  | Object | |
| data : Vector.<BitmapData>  
		A Vector of BitmapData objects containing the cursor image or images.  | MouseCursorData | ||
| frameRate : Number  
		The frame rate for animating the cursor.  | MouseCursorData | ||
| hotSpot : Point  
		The hot spot of the cursor in pixels.  | MouseCursorData | ||
| Method | Defined By | ||
|---|---|---|---|
 
        	Creates a MouseCursorData object.  | MouseCursorData | ||
![]()  | 
	 Indicates whether an object has a specified property defined.  | Object | |
![]()  | 
	 Indicates whether an instance of the Object class is in the prototype chain of the object specified 
	 as the parameter.  | Object | |
![]()  | 
	 Indicates whether the specified property exists and is enumerable.  | Object | |
![]()  | 
     Sets the availability of a dynamic property for loop operations.  | Object | |
![]()  | 
	 Returns the string representation of this object, formatted according to locale-specific conventions.  | Object | |
![]()  | 
	 Returns the string representation of the specified object.  | Object | |
![]()  | 
	 Returns the primitive value of the specified object.  | Object | |
data | property | 
data:Vector.<BitmapData>| Language Version: | ActionScript 3.0 | 
| Runtime Versions: | Flash Player 10.2, AIR 2.6 | 
A Vector of BitmapData objects containing the cursor image or images.
Supply more than one image and set the framerate property to
		animate the cursor.
The maximum cursor size is 32x32 pixels.
Implementation
    public function get data():Vector.<BitmapData>    public function set data(value:Vector.<BitmapData>):voidframeRate | property | 
frameRate:Number| Language Version: | ActionScript 3.0 | 
| Runtime Versions: | Flash Player 10.2, AIR 2.6 | 
The frame rate for animating the cursor.
Suppy more than one image in the data property and set the 
		frame rate to a value greater than 0 to animate the cursor. The cursor frame rate 
		may differ from the current SWF frame rate.
Implementation
    public function get frameRate():Number    public function set frameRate(value:Number):voidhotSpot | property | 
hotSpot:Point| Language Version: | ActionScript 3.0 | 
| Runtime Versions: | Flash Player 10.2, AIR 2.6 | 
The hot spot of the cursor in pixels.
The hotspot is the point on the cursor under which mouse clicks are registered. By default, the hot spot is the upper-left corner (0,0).
Implementation
    public function get hotSpot():Point    public function set hotSpot(value:Point):voidMouseCursorData | () | Constructor | 
public function MouseCursorData()| Language Version: | ActionScript 3.0 | 
| Runtime Versions: | Flash Player 10.2, AIR 2.6 | 
Creates a MouseCursorData object.
To display the cursor, call the Mouse.registerCursor() function.
Related API Elements
The example uses the drawing commands available through the Graphics class to create
 eight, rotated images of an arrow. These images are pushed into a vector and assigned to the data
 property of the MouseCursorData object. (Note that you can also use prerendered bitmap images for your cursors.)
package  {
    
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.BitmapData;
    import flash.display.GraphicsPath;
    import flash.ui.MouseCursorData;
    import flash.ui.Mouse;
    import flash.geom.Matrix;    
    
    public class MouseCursorDataExample extends Sprite {
        //Graphics path data for an arrow
        private var cursorPoints:Vector.<Number> = new <Number>[0,8, 16,8, 16,0, 24,12, 16,24, 16,16, 0,16, 0,8];
        private var cursorDrawCommands:Vector.<int> = new <int>[1,2,2,2,2,2,2,2];
        
        public function MouseCursorDataExample() {
            var mouseCursorData:MouseCursorData = new MouseCursorData();
            mouseCursorData.data = makeCursorImages();
            mouseCursorData.frameRate = 1;
            
            Mouse.registerCursor( "spinningArrow", mouseCursorData );
            Mouse.cursor = "spinningArrow";
        }
        
        //Returns a Vector containing 8 cursor images
        private function makeCursorImages():Vector.<BitmapData>
        {
            var cursorData:Vector.<BitmapData> = new Vector.<BitmapData>();
            
            var cursorShape:Shape = new Shape();
            cursorShape.graphics.beginFill( 0xff5555, .75 );
            cursorShape.graphics.lineStyle( 1 );
            cursorShape.graphics.drawPath( cursorDrawCommands, cursorPoints );
            cursorShape.graphics.endFill();
            var transformer:Matrix = new Matrix();
            
            //Rotate and draw the arrow shape to a BitmapData object for each of 8 frames 
            for( var i:int = 0; i < 8; i++ )
            {
                var cursorFrame:BitmapData = new BitmapData( 32, 32, true, 0 );
                cursorFrame.draw( cursorShape, transformer );
                cursorData.push( cursorFrame );
                
                transformer.translate(-15,-15);
                transformer.rotate( 0.785398163 );
                transformer.translate(15,15);
            }
            return cursorData;
        }
    }
    
}
Thu Dec 4 2014, 05:50 PM -08:00
 