Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

animated custom cursor

Explorer ,
Feb 19, 2012 Feb 19, 2012

hi

I propose this code, it produces an animate cursor:

package 

{

          import flash.display.Sprite;

          import flash.ui.Mouse;

          import flash.ui.MouseCursorData;

          import flash.display.Bitmap;

          import flash.display.BitmapData;

          import flash.geom.Point;

          import flash.geom.Rectangle;

          public class hourglass extends Sprite

          {

                    [Embed(source='immi/busy.png', mimeType = 'image/png')]

                    private var a_busy:Class;

                    public function hourglass()

                    {     var mcd:MouseCursorData = new MouseCursorData();

                          mcd.data = new Vector.<BitmapData>();

                          var b:Bitmap = new a_busy as Bitmap;

                          var h:uint = b.height;

                          for( var i:int = 0; i < int(b.width/h); i++ )

                                                       { var bmp:BitmapData = divBmp(b,new Point(i*h,0)); mcd.data.push( bmp ); }

                          mcd.frameRate = 10;

                          mcd.hotSpot = new Point(h/2-1,h/2-1);

                          Mouse.registerCursor('hourglass',mcd);

                     }

                    private function divBmp(bmp:Bitmap,pos:Point):BitmapData

                    {

                              var imBase:BitmapData = new BitmapData(bmp.width,bmp.height,true,0);

                              imBase.draw(bmp);

                              var immy:BitmapData = new BitmapData(bmp.height,bmp.height,true,0);

                              immy.copyPixels(imBase,

                                                                      new Rectangle(pos.x,pos.y,bmp.height,bmp.height),

                                                                      new Point(0,0));

                              return immy;

                    }

          }

}

where immi/busy.png is an image whit a certain number of square images

now with the code:

     new hourglass;    

     Mouse.cursor = "hourglass";

we can activate the animate cursor, and it works correctly in an simple application of test where works alone, but if I use it in a real application, for example downloading a host file, only one of the frames are displayed.

It seems that don't find the temporal space to advance the frames.

any opinion?

thanks in advance

JeanPaul


TOPICS
ActionScript
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2012 Feb 19, 2012

i don't see a problem using an animated cursor during file loads.  however, if you're also doing something (like a lengthy for-loop) that stops the stage from updating, that would cause a problem with all animation.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2012 Feb 19, 2012

of course, i know that any loop removes space from the multitasking, and can also stop the system...but the download is an asyncronous operation that leaves a lot of space to the other elaborations and, however, it was only  an example, the same problem happens if I make an upload, or I read in local file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2012 Feb 19, 2012

are you using flash pro cs5.5?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2012 Feb 19, 2012

yes, with XP34 SO

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2012 Feb 19, 2012

i have no idea what xp34 so is.   in any case, because there's no problem using an animated cursor during a file load and you're having a problem, someone will probably need to download your file to see what you're doing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2012 Feb 19, 2012

pardon , no XP34 but XP32 (winXP32 operating system).

OK, perhaps I must to perform other tests before saying other

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2012 Feb 20, 2012
LATEST

i'd recommend creating a test file that contains only the code you showed and only the additional code needed to download a file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines