[英]Depth management in as3
我有很多紙牌精靈。 它們在列表中,父卡位於頂部,后跟一個孩子,該孩子是另一個孩子的父母。
例如,當我單擊樁中的第4個時,我希望它及其所有子項都位於頂部。 我怎樣才能做到這一點?
currentCard.parent.setChildIndex(currentCard, numChildren-1);
currentCard是用戶單擊的卡。
上面出現了一個錯誤,提供的索引超出范圍。
嘗試:
currentCard.parent.setChildIndex(currentCard, currentCard.parent.numChildren-1);
否則, numChildren
將this
引用。 我不確定this
將是什么,因為您只有那行代碼,但是如果不是currentCard.parent
那么numChildren
可能很容易成為子孫,而不是currentCard.parent
有多少子孫,從而導致邊界錯誤。 例如,如果this
有17個孩子,而currentCard.parent
有5個孩子,則該行代碼意味着您將嘗試訪問顯然超出范圍的索引16。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.