-
thank you for checking,
i'm trying to sort an array with its .sort()-method.
what i have is:
39,58,18,-40,-19,-59
after sorting it looks like this:
-19,-40,-59,18,39,58
now, that ain't right!
but i want it right! how to?
*marc
-
ok, addition:
i really can't work my head around it, duh...
what i actually want to is, i have 6 MCs, generated with duplicateMovieClip, on level10 - 15.
they move in a circle, but not flat on the screen. they#re moving in and out of the screen and in doing so, are changing position relative to each other. an MC that was covered by another one could by on top the next moment. clear?
BUT I CAN'T WORK WITH swapDepth AND SORTING AND ALL, CAUSE I'M TOO STUPID!
gimme a hint, pleeeeeeaaze!
-
try to use simple sorting function, it will work:
function sortNumbers (a,b) {
if (a < b) { return -1}
if (a == b) {return 0}
if (a > b) {return 1}
}
yourArray.sort(sortNumbers)
Alex
-
rock AND roll! alex, thanks.
very smooth.
haven't figured out that swapDepth-thing yet but i'm very optimistic.
later, *marc
-
hi, your post caught my eye 'cos I was talking to somebody else about this
see:
http://board.flashkit.com/board/show...hreadid=242533
You can't retrieve a mc's depth value from itself (unfortunately) so better to define right at the start and stick the values into an array. When I was doing something similiar I had a distance property, which was basically the distance from the viewer. This was the property that the array was sorted on, and the dpeths were then sorted out after that.
Hope this helps
Keith
-
thanks, keith.
yeah, guess you're right. i was hoping for something more...well less..., something.
so, let's get going
thanks a lot!
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
|