How use swapDepths & getNextHighestDepth() in AS3?

强颜欢笑 提交于 2020-01-15 17:17:43

问题


I'm trying to convert the following code:

DNA0.swapDepths(this.getNextHighestDepth())

I tried it this way:

DNA0.swapChildren(stage.getChildIndex(DNA0));

But its not working... I guess I didn't understand the logic. Anybody help me?

----EDIT---- @gladoscc, good job. it's work. But I have other convert problems..

Like,

this['DNA'+DNAsy.length].y = this['DNA'+(DNAsy.length-1)].y;
this['DNA'+DNAsx.length].x = this['DNA'+(DNAsy.length-1)].x;
DNAsy.push(this['DNA'+DNAsy.length].y)
DNAsx.push(this['DNA'+DNAsx.length].x)

I guess, I will ask a new question...


回答1:


DNA0.parent.setChildIndex( DNA0, DNA0.parent.numChildren -1 );

You can replace DNA0.parent with the DNA0 container reference:

cont.setChildIndex( DNA0, cont.numChildren -1 );



回答2:


If you want to bring to front, just:

setChildIndex(myMC,numChildren – 1)


来源:https://stackoverflow.com/questions/11678038/how-use-swapdepths-getnexthighestdepth-in-as3

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