AS3 How can I solve the bug of setChildIndex

倾然丶 夕夏残阳落幕 提交于 2019-12-13 05:30:58

问题


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.

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.

Thank you

-Ozan


回答1:


Instead of this:

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

You can simply use this:

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

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)



来源:https://stackoverflow.com/questions/19757149/as3-how-can-i-solve-the-bug-of-setchildindex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!