作者:mobiledu2502885243 | 来源:互联网 | 2023-05-18 00:47
Imalong-timeActionScript2user,nowgettingstartedwithActionScript3.TheonethingImmiss
I'm a long-time ActionScript 2 user, now getting started with ActionScript 3. The one thing I'm missing is an easy way to duplicate the functionality of AS2's MovieClip.onReleaseOutside. It is almost always necessary to implement this event, otherwise you get funny bugs like flash thinks your mouse is down when really it's up.
我是一个长期的ActionScript 2用户,现在开始使用ActionScript 3.我缺少的一件事是复制AS2的MovieClip.onReleaseOutside功能的简单方法。几乎总是有必要实现这个事件,否则你会得到一些有趣的错误,比如flash认为你的鼠标已经关闭了。
According to the AS2 to AS3 Migration Guide, I'm supposed to use flash.display.InteractiveObject.setCapture()
for this, however it does not exist as far as I can tell. I guess this document is out of date or incorrect. I've found a few posts on the web about how to duplicate this functionality, but they either have their own problems:
根据AS2到AS3迁移指南,我应该为此使用flash.display.InteractiveObject.setCapture(),但据我所知,它不存在。我猜这个文件已经过时或不正确。我在网上发现了一些关于如何复制这个功能的帖子,但是他们有自己的问题:
- This one triggers onReleaseOutside even if there was no corresponding onPress event.
即使没有相应的onPress事件,也会触发onReleaseOutside。
- This one seems very inefficient, you'll add and remove an event listener every time the mouse is clicked anywhere inside your app.
这个效率似乎非常低效,每次在应用程序内的任何位置单击鼠标时,您都会添加和删除事件侦听器。
There has to be an easier way, don't tell me Adobe forgot about this when rewriting Actionscript?
必须有一个更简单的方法,不要告诉我Adobe在重写ActionScript时忘了这个吗?
Example AS2 code:
示例AS2代码:
// Assume myMC is a simple square or something on the stage
myMC.OnPress= function() {
this._rotation = 45;
}
myMC.OnRelease= myMC.OnReleaseOutside= function() {
this._rotation = 0;
}
Without the onReleaseOutside handler, if you pressed down on the squre, dragged your mouse outside of it, and released the mouse, then the square would not un-rotate, and appear to be stuck.
没有onReleaseOutside处理程序,如果你按下squre,将鼠标拖到它外面,然后松开鼠标,那么方块就不会旋转,并且看起来卡住了。
3 个解决方案