|
-
Senior Member
AS3 noob question
Sorry to post this in the games forums, but you guys are speed/optimization oriented and I was looking for the right method to use in a game and not something that would just be done every 10 seconds or so (and the example I found seemed overly elaborate).
I am new at AS3, so my obvious growing pains are the new event system and the new depth sorting. I am liking both so far over the inconsistency of AS2, but they are taking practice, and I am missing a lot of tricks. I know about making container sprites to hold basic layers (background, tiles, characters, interface), but sometimes you want to bring an object to the front of it's container.
So, what is the 'best' way to move a movieclip to the top of the z index of the display list.
1) The obvious question is, is there a swap method I have missed that will put it at the top? Or a function that will return the highest z for a given container?
2) Is it reasonalbe to just remove the child and re-add it? This would put it at the top, and I don't think any associated properties would be lost since it would still be in memory after removeChild, right? Would this be slow if used a lot? Would it work? Would this cause it to flicker?
3) On the web I found the following snippet. This seems like a time waster to me if you have a lot of objects like in an action game. But if option 2 is not feasible (or slow) it might be a solution.
PHP Code:
function docjslib_findHighestZ() {
var documentDivs = new Array();
documentDivs = document.all.tags("DIV");
var highestZ = 0;
for (var i = 0; i < documentDivs.length; i++) {
var Zindex = documentDivs[i].style.zIndex;
if (Zindex > highestZ) {
highestZ = Zindex;
}
}
return highestZ;
}
What do you folks use?
Last edited by Alluvian; 05-21-2009 at 10:15 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|