本文介绍了AS3:定义点击区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个影片剪辑,其中包含一个位图,我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.

这篇关于AS3:定义点击区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:46