Attach() 或事件监听器(例如 onTweenComplete、onTweenUpdate)
我有一个对象的实例,它启动和停止子影片剪辑的补间。不过,我想在补间完成后做一些事情。
所以我想为事件分配一个调用对象;例如 attach()
函数的作用。然而,当在事件上使用attach()函数时,它会立即使用正确的对象进行调用,但是当事件被触发时,它会使用执行事件的对象进行调用(在我的例子中是子对象)。电影剪辑)。
如果那不可能;类似于鼠标事件和 MouseListener 工作方式的东西也可以满足我的需求 Mouse.addListener(this)
。通过向当前对象添加特定事件的侦听器,然后当调用这些事件时,它们将在我们自己的对象上调用。
我还看到了一些我并不真正喜欢的聪明的解决方案,因为它们不是很好:
var myObject = this;
myMovieClip.onTweenComplete = function() {
myObject.doStuff();
}
还有比这更好的东西吗?
I have an instance of an object that starts and stops tweens for sub-movieclips. However I want to do stuff when the tween is finished.
So I would like to assign a calling object to events; such as the attach()
function does. However when using the attach()
function on events it is called right away with the correct object, but when the event is triggered it is called with the object that executed the event (in my case the sub-movieclip).
If that's not possible; something similar to how Mouse events and MouseListeners work would also fit my needs Mouse.addListener(this)
. By adding a listener for specific events to the current object, then when these events are called they are called on our own object.
I also saw some clever solutions that I do not really enjoy since they are not very nice:
var myObject = this;
myMovieClip.onTweenComplete = function() {
myObject.doStuff();
}
Is there something nicer than this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1) 我不知道 Actionscript 2 中有
attach()
函数。2) 有一些有用的提示 此处介绍如何使用
onMotionFinished
事件。3) 无论好坏,您都可以通过导入 来使用
onTweenComplete
MCTween 库。希望这有帮助。
1) I'm not aware of an
attach()
function in Actionscript 2.2) There are some useful tips here on how to use the
onMotionFinished
event.3) Nice or not, you can use
onTweenComplete
by importing the MCTween library.Hope this helps.