我正在使用 ActionScript 3 开发一个 Flash 项目。
我们的界面通过添加和删除主舞台的直接子级在不同模式之间切换——我们称之为场景。
我遇到的问题是:其中一个场景有一个 SimpleButton (flash.display.SimpleButton) 具有不同的 up 和 over 状态。当我将鼠标悬停在按钮上时,它会按预期进入过度状态。但是如果应用程序自动切换到一个新场景(在这种情况下,视频结束并且应用程序继续运行)然后用户导航回来(导致重新添加原始场景),按钮将保持在 over 状态,直到我将鼠标移回然后再次移出。我希望能够强制该按钮回到其向上状态。
我尝试设置 b.overState = b.upState,但随后的翻转没有外观变化。我也尝试将 ROLL_OUT 事件分派(dispatch)给按钮对象,但这也无济于事。
除了从头开始实现某些东西之外,还有什么想法可以揭示一种强制改变状态的方法吗?
最佳答案
这是我必须做的:
// store ref to normal over state
var overState = myBtn.overState;
// since we cant change the state, change the over state's asset to the up state
myBtn.overState = myBtn.upState;
// since we want the state to change on mouse over, reset the overstate once it rolled over again
myBtn.addEventListener(MouseEvent.MOUSE_OVER, function(e){
myBtn.overState = overState;
})
它不是太漂亮,但它有效。就我而言,当我将按钮父级渲染到显示列表时,我会触发此交换逻辑。如果您使用的是场景,您可能可以在场景变回带有按钮的场景后执行此操作。
关于Flash SimpleButton 停留在过度状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6944531/