zoukankan      html  css  js  c++  java
  • 在Flash Player 10.2中使用原生鼠标指针

    Adobe Flash Player 10.2 版本引入了一个引人注目的新特性:原生鼠标指针。您现在可以使用运行在操作系统层的基于位图的鼠标指针。

    实现原生鼠标指针

    flash.ui 包中的 MouseCursorData 对象

    MouseCursorData 对象的三个属性:

    • MouseCursorData.data用于显示鼠标指针的 BitmapData 对象向量。
    • MouseCursorData.hotSpot鼠标指针的定位点值,保存为一个 Point 对象。
    • MouseCursorData.frameRate用于实现位图图像序列动画的帧频。这个属性允许您创建动画鼠标指针。

    在创建一个 MouseCursorData 对象之后,您要使用 Mouse.registerCursor 方法将它赋值给 Mouse 对象。一旦注册了 Mouse 对象,您可以将别名传递给 Mouse.cursor 属性。

    说明:通过传递一个 BitmapData ,您就可以通过指定一系列的位图鼠标指针来创建一个原生的动画指针。

    请查看以下示例代码:

     1 // Create a MouseCursorData object
     2 var cursorData:MouseCursorData = new MouseCursorData();
     3 // Specify the hotspot
     4 cursorData.hotSpot = new Point(15,15);
     5 // Pass the cursor bitmap to a BitmapData Vector
     6 var bitmapDatas:Vector.<BitmapData> = new Vector.<BitmapData>(1, true);
     7 // Create the bitmap cursor
     8 // The bitmap must be 32x32 pixels or smaller, due to an OS limitation
     9 var bitmap:Bitmap = new zoomCursor();
    10 // Pass the value to the bitmapDatas vector
    11 bitmapDatas[0] = bitmap.bitmapData;
    12 // Assign the bitmap to the MouseCursor object
    13 cursorData.data = bitmapDatas;
    14 // Register the MouseCursorData to the Mouse object with an alias
    15 Mouse.registerCursor("myCursor", cursorData);
    16 // When needed for display, pass the alias to the existing cursor property
    17 Mouse.cursor = "myCursor";

    一定要记住,由于操作系统的限制,鼠标指针所使用的这些位图文件不能大于 32 × 32 像素。传递一个大于此限制的位图会出错。

    无论任何时候,您都可以停止使用当前的位图鼠标指针,而切换回显示默认操作系统鼠标指针。要实现这一点,您可以使用 MouseCursor 类的其中一个常量值,如下所示:

    1 Mouse.cursor = MouseCursor.AUTO;

    上一个例子创建了一个静态位图鼠标指针;下一个例子将创建一个动画鼠标指针。这个过程是很简单的 —— 只需要先提供多个位图图像,然后指定鼠标指针动画的帧频,如下所示:

     1 // Create a MouseCursorData object
     2 var cursorData:MouseCursorData = new MouseCursorData();
     3 // Specify the hotspot
     4 cursorData.hotSpot = new Point(15,15);
     5 // Pass the cursor's bitmap to a BitmapData Vector
     6 var bitmapDatas:Vector.<BitmapData> = new Vector.<BitmapData>(3, true);
     7 // Create the bitmap cursor frames
     8 // Bitmaps must be 32 x 32 pixels or less, due to an OS limitation
     9 var frame1Bitmap:Bitmap = new frame1();
    10 var frame2Bitmap:Bitmap = new frame2();
    11 var frame3Bitmap:Bitmap = new frame3();
    12 // Pass the values of the bitmap files to the bitmapDatas vector
    13 bitmapDatas[0] = frame1Bitmap.bitmapData;
    14 bitmapDatas[1] = frame2Bitmap.bitmapData;
    15 bitmapDatas[2] = frame3Bitmap.bitmapData;
    16 // Assign the bitmap data to the MouseCursor object
    17 cursorData.data = bitmapDatas;
    18 // Pass the frame rate of the animated cursor (1fps)
    19 cursorData.frameRate = 1;
    20 // Register the MouseCursorData to the Mouse object
    21 Mouse.registerCursor("myAnimatedCursor", cursorData);
    22 // When needed for display, pass the alias to the existing cursor property
    23 Mouse.cursor = "myAnimatedCursor";

    通过设置 MouseCursorData.frameRate 属性并传入一系列 BitmapData 对象,Flash Player 就会自动创建出一个以指定帧频播放的动画鼠标指针。这是一个自动化的过程,所以您不需要编写任何代码就能够实现动画鼠标指针。

  • 相关阅读:
    oracle数据库连接不上
    Oracle的regexp_instr函数简单用法
    Oracle中dbms_random.string 的用法
    oracle 简单输出语句与赋值
    oracle中sequence(自增序号)的用法
    oracle 函数的返回值与out参数
    SQL%ROWCOUNT作用
    100多个基础常用JS函数和语法集合大全
    题解【AcWing272】最长公共上升子序列
    题解【POJ1062】昂贵的聘礼
  • 原文地址:https://www.cnblogs.com/atong/p/3056345.html
Copyright © 2011-2022 走看看