AS3:定义点击区域定义、区域

由网友(我有自己的专场)分享简介:我有一个影片剪辑,其中包含一个位图,我wan't,以增加点击区域。我知道我可以添加一个透明形状,其背后但这是通过空气被编译为iOS,我不希望引起不必要的重绘。I have a movieclip which contains a bitmap and I wan't to increase the hit area....

我有一个影片剪辑,其中包含一个位图,我wan't,以增加点击区域。我知道我可以添加一个透明形状,其背后但这是通过空气被编译为iOS,我不希望引起不必要的重绘。

I have a movieclip which contains a bitmap and I wan't to increase the hit area. I understand I can add a transparent shape behind it but this is to be compiled through air for ios and I don't want to cause unnecessary redraws.

有没有一种方法来定义一个矩形的点击区域或其他解决办法吧?

Is there a way to define a rectangle as the hit area or another solution perhaps?

推荐答案

没有用于该用途的特殊hitArea场。

There is a special hitArea field for that purposes.

  const MOUSE_ZONE_SIZE:Number = 10;
  const hitArea:Sprite = new Sprite()
  hitArea.graphics.beginFill( 0xFFFFFF );
  hitArea.graphics.drawRect( -MOUSE_ZONE_SIZE, -MOUSE_ZONE_SIZE, MOUSE_ZONE_SIZE* 2, MOUSE_ZONE_SIZE* 2 );
  hitArea.mouseEnabled = false;
  hitArea.visible = false;
  hitArea.x = bitmap.x
  hitArea.y = bitmap.y
  bitmap.hitArea = hitArea;
  addChild( bitmap );
  addChild( hitArea );

不幸的是,即使你覆盖的hitTest *的InteractiveObject的功能,他们将不会被用于鼠标事件的调度:(如果有人知道如何强制闪光使用覆盖的方法 - 我想知道它太

Unfortunately even if you override hitTest* function of InteractiveObject they will not be used for mouse-events dispatching :( If somebody knows how to force Flash to use overridden methods - I'd like to know it too.

阅读全文

相关推荐

最新文章