Flex [original] uses bitmapdata to set the cursor Style

Source: Internet
Author: User

These days I suddenly found that the traditional use of cursormanager. setcursor (...); set the cursor style will have a bad feeling.

Now you can use bitmapdata to implement this function, and the performance is much better. I don't want to explain it. On the source code, you know!

Cursor class:

View code

 Package  {  Import  Flash. display. Bitmap;  Import  Flash. display. bitmapdata;  Import  Flash. display. loader;  Import  Flash. Events. event; Import  Flash.net. URLRequest;  Import  Flash. UI. Mouse;  Import  Flash. UI. mousecursordata;  Public   Class  Cursor {  Private  VaR _ cursor: array;  Private  VaR Loader: loader;  Public Function cursor (cursor: array ){  This . Cursor = Cursor ;}  Public  Function get cursor (): Array {  Return  _ Cursor ;}  Public Function set cursor (value: array ): Void  {_ Cursor = Value;  If (_ Cursor & _ cursor. Length = 2) {Loader = New  Loader (); loader. contentloaderinfo. addeventlistener (event. Complete, oncomplete); loader. Load (  New URLRequest (_ cursor [1 ]) ;}}  Protected Function oncomplete (Event: Event ): Void  {Var cursordata: vector. <Bitmapdata> = New Vector. <bitmapdata>(); Cursordata .push(bitmap(event.tar get. Content). bitmapdata); var mousecursordata: mousecursordata = New  Mousecursordata (); mousecursordata. Data = Cursordata; mouse. registercursor (_ cursor [ 0 ], Mousecursordata); mouse. cursor = _ Cursor [0 ] ;}}} 

 

Call: input an array. The index 0 is the name of the cursor, and the index 1 is the image path of the cursor.

New cursor (["newcursor", config. cursor_blue]);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.