AS3如何解决setChildIndex的错误 [英] AS3 How can I solve the bug of setChildIndex

查看:132
本文介绍了AS3如何解决setChildIndex的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将所有游戏页面收集在称为游戏的Movieclip的不同帧上.在该游戏的动画片段中,有4种不同的帧.在第三帧上,我有一些拖动&放下功能.当我拖动一个项目时,我希望它位于最前面,这意味着该框架上的所有其他对象都不得遮挡当前拖动对象的视图.我使用了this.setChildIndex(currentDraggingObject,this.numChildren-1);但是问题是,每当我拖动对象,更改框架时,这些对象也会显示在该框架上.

I've gathered all game pages on different frames of movieclip called game. in that game movieclip there are 4 different frames. on third frame I have some drag & drop functionality. When I drag one item, I want it to be on the front, I mean all other objects on that frame must not block the view of current dragging object. I used this.setChildIndex(currentDraggingObject,this.numChildren-1); but the problem is whenever I drag objects, when I change the frame, those objects are shown on that frames as well.

简而言之:当我在MovieClip(game)中设置对象的索引时,该对象会在MovieClip(game)的每一帧中出现,该如何解决呢?

In short description: When I set an object's Index in MovieClip(game) , that object is seen in each frame of MovieClip(game) , how can I fix this?

我已经在线搜索了结果,但是找不到解决方案.

I've searched the result online but couldn't find a solution.

谢谢

-奥赞

推荐答案

代替此:

this.setChildIndex(currentDraggingObject,this.numChildren-1);

您可以简单地使用它:

this.addChild(currentDraggingObject); //shorter and clearer

如果您在一个框架上有某个对象并且实际上又添加了它,则它确实会留在其他框架中(我也发现了这一点).最好/最快的解决方案是在使用this.removeChild(object)

If you have some object on a frame and you actually add it again, it indeed stays there in the other frames (I found this out too). The best/fastest solution would be to simple remove them before you are going to change the frame with this.removeChild(object)

这篇关于AS3如何解决setChildIndex的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆