Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 是否将鼠标光标更改为位图(Flex 4)?_Apache Flex_Flex4 - Fatal编程技术网

Apache flex 是否将鼠标光标更改为位图(Flex 4)?

Apache flex 是否将鼠标光标更改为位图(Flex 4)?,apache-flex,flex4,Apache Flex,Flex4,在Flex4中,如何将光标更改为运行时确定的位图图像?我看到的所有示例都使用CursorManager.setCursor将游标设置为编译时指定的类 我要做的是将光标更改为位图,其位图数据由上下文确定 package cursor { import flash.display.BitmapData; import flash.display.PixelSnapping; import mx.core.BitmapAsset; public class RuntimeBitmap1 exten

在Flex4中,如何将光标更改为运行时确定的位图图像?我看到的所有示例都使用CursorManager.setCursor将游标设置为编译时指定的类

我要做的是将光标更改为位图,其位图数据由上下文确定

package cursor
{
import flash.display.BitmapData;
import flash.display.PixelSnapping;

import mx.core.BitmapAsset;

public class RuntimeBitmap1 extends BitmapAsset
{

    public static var staticBitmapData:BitmapData;

    public function RuntimeBitmap1()
    {
        super(staticBitmapData);
    }
}
}
用法:

var bitmapData:BitmapData = new BitmapData(50, 50, false, 0x88888888);
RuntimeBitmap1.staticBitmapData = bitmapData;
cursorManager.setCursor(RuntimeBitmap1, 0);
用法:

var bitmapData:BitmapData = new BitmapData(50, 50, false, 0x88888888);
RuntimeBitmap1.staticBitmapData = bitmapData;
cursorManager.setCursor(RuntimeBitmap1, 0);

以下是使用位图图像更改默认光标的几个简单步骤:

  • 使用您选择的图像创建位图类型的光标。您还可以在运行时动态设置位图数据。
    
    
    
    var DEFAULT_CURSOR_IMAGE : Class;
    var myCursorBitmap : Bitmap;
    ...
    myCursorBitmap = new DEFAULT_CURSOR_IMAGE();
    var DEFAULT\u CURSOR\u IMAGE:Class; var-myCursorBitmap:位图; ... myCursorBitmap=新的默认光标图像()
  • 注册以接收鼠标移动事件并相应地更新光标位置。
    
    
    
    function onMouseMove(event : MouseEvent) : void
    {
       myCursorBitmap.x = event.localX;
       myCursorBitmap.y = event.localY;
    }
    mouseMove函数(事件:MouseEvent):void { myCursorBitmap.x=event.localX; myCursorBitmap.y=event.localY; }
  • 使用鼠标隐藏实际光标。Hide()

  • 显示自定义光标。以后可以通过动态设置位图数据来更新光标形状。
    
    
    
    addChild(myCursorBitmap);
    ...
    myCursorBitmap.bitmapData = myNewCursor;
    addChild(myCursorBitmap); ... myCursorBitmap.bitmapData=myNewCursor


  • 要还原默认光标,请从后台删除光标位图并调用Mouse.show()。

    以下是使用位图图像更改默认光标的几个简单步骤:

  • 使用您选择的图像创建位图类型的光标。您还可以在运行时动态设置位图数据。
    
    
    
    var DEFAULT_CURSOR_IMAGE : Class;
    var myCursorBitmap : Bitmap;
    ...
    myCursorBitmap = new DEFAULT_CURSOR_IMAGE();
    var DEFAULT\u CURSOR\u IMAGE:Class; var-myCursorBitmap:位图; ... myCursorBitmap=新的默认光标图像()
  • 注册以接收鼠标移动事件并相应地更新光标位置。
    
    
    
    function onMouseMove(event : MouseEvent) : void
    {
       myCursorBitmap.x = event.localX;
       myCursorBitmap.y = event.localY;
    }
    mouseMove函数(事件:MouseEvent):void { myCursorBitmap.x=event.localX; myCursorBitmap.y=event.localY; }
  • 使用鼠标隐藏实际光标。Hide()

  • 显示自定义光标。以后可以通过动态设置位图数据来更新光标形状。
    
    
    
    addChild(myCursorBitmap);
    ...
    myCursorBitmap.bitmapData = myNewCursor;
    addChild(myCursorBitmap); ... myCursorBitmap.bitmapData=myNewCursor


  • 要恢复默认光标,请从后台删除光标位图并调用Mouse.show()。

    我想将UIComponent绘制为光标

    我把格言和答案结合在一起。我对Maxim答案所做的唯一更改如下:

    public function RuntimeBitmap1()
    {
        super(RuntimeBitmap1.staticBitmapData);
    }
    

    否则,staticBitmapData在构造函数中以null的形式出现。

    我想画一个UIComponent作为光标

    我把格言和答案结合在一起。我对Maxim答案所做的唯一更改如下:

    public function RuntimeBitmap1()
    {
        super(RuntimeBitmap1.staticBitmapData);
    }
    

    否则,staticBitmapData在构造函数中显示为null。

    这是一个Flex项目,因此我无法将Child添加到主mxml类。@justkevin:是的,你说得对-在这种情况下,你必须将其放置在UIComponent中。这是一个Flex项目,因此我无法将Child添加到主mxml类。@justkevin:是的,你说得对——在这种情况下,你必须把它放在一个UIComponent中。