如何在动作脚本3中强制或锁定焦点?

时间:2010-02-18 22:47:56

标签: actionscript-3

我想创建一个对话框或警告框,其中一个DisplayObject会占用并强制聚焦,直到一个好的按钮或某个东西释放锁。感谢。

3 个答案:

答案 0 :(得分:4)

这样做的简单方法是让你的“对话框”与舞台一样大,在对话框周围有一个非常透明的区域。

透明区域可以监听任何鼠标点击,只是吞下它们(这将阻止它们被显示列表中的其他东西拾取)。

要显示警报,只需将其粘贴在其他所有内容上,当用户关闭它时,再将其取出。

答案 1 :(得分:1)

为此,您需要禁用对“alert”DisplayObject下所有对象的访问权限。有多种方法可以做到这一点,这里我可以想一想:

  1. 循环显示列表并禁用警报深度下的所有显示对象。
  2. 用拦截器作弊。显示警报时,显示另一个剪辑(可能将alpha设置为0),阻止用户悬停/单击对象。阻止程序可能需要一些设置(buttonMode = true,useHandCursor = false等)
  3. 这种“模态”行为已经存在,因此根据您当前的设置,可能不需要重新发明轮子。

    如果您正在使用Flex框架,那么您已经拥有了Flash功能,您可以使用Alert Manager from the Yahoo! Flash Astra Components

    alert manager thumb http://developer.yahoo.com/flash/astra-flash/alertmanager/images/emailForm.gif

    古德勒克,

答案 2 :(得分:1)

如果您使用的是flex和actionscript,只需使用SkinnablePopUpContainer

即可
var alt:CustomPopUp = new CustomPopUp();
alt.open(this,true) //the second variable is for modal, which will disable view
this.enabled = false; //this will grey out the parent view and provide visual focus to your popup.