由网友(醉生梦死﹌)分享简介:我找不到更好的称谓来形容我的问题。I couldn't find a better title to describe my problem.我要做到这一点:for(var i:int = 0; i < 10; i++) {var mc:MovieClip = new MovieClip();mc.addEven...
我找不到更好的称谓来形容我的问题。
I couldn't find a better title to describe my problem.
我要做到这一点:
for(var i:int = 0; i < 10; i++) {
var mc:MovieClip = new MovieClip();
mc.addEventLister(MouseEvent.MOUSE_OVER, function() {
mc.y=-20;
});
}
我的问题是三菱商事总是referrs到最后MC在for循环创建,这样创建的第一个MC使最后一个将鼠标悬停。也许我可以使用类似这个或自我......
My problem is that mc always referrs to the last mc created in the for loop so the first mc created causes the last one to move on mouseover. Maybe I could use something like "this" or "self"...
有什么建议?
推荐答案
您想要做这样的事情:
for(var i:int = 0; i < 10; i++) {
var mc:MovieClip = new MovieClip();
mc.addEventLister(MouseEvent.MOUSE_OVER, function(evt:Event) {
evt.currentTarget.y=-20;
});
}
请注意,这不是使用 MC
我使用了 currentTarget当前
事件中,这是我们添加的事件监听器。
Note, that instead of using mc
I'm using the currentTarget
of the event, which is what we added the event-listener to.
相关推荐
最新文章