Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4382058
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:43:48+00:00 2026-05-21T12:43:48+00:00

Any smart people out there who can tell me why this function Im working

  • 0

Any smart people out there who can tell me why this function Im working on to automatically sort the depths of objects placed on the 3D plane is only working intermittently? It seems to work every second or third iteration?

    function zsort(h){
        var zpos=[] //array to store Z positions
        var mc,mcZpos
        for(var i=0; i<h.numChildren-1; i++){
            mc = h.getChildAt(i);
            mcZpos=(mc.z - (Math.sin(mc.rotationX) * mc.height/2)) //get lowest Z point based on X rotation
            zpos.push([mcZpos, mc])
        }
        zpos.sort()
        for(i in zpos){
            h.setChildIndex(zpos[i][1], h.numChildren-1)
        }
    }

Is getChildAt(i) reliable? IE does it return the same order each time it runs or is it based on depth?

EDIT: looking at the manual suggests that it’s probably the latter so I guess I’ll need to make my own array ordered by the time the sprites were added to the parent and work from there. Is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:43:49+00:00Added an answer on May 21, 2026 at 12:43 pm

    This class works, could probably be optimized but it works and should be a good start:

    http://blog.theflashblog.com/?p=470

    http://code.google.com/p/leebrimelow/source/browse/#svn%2Ftrunk%2Fas3%2Fcom%2Ftheflashblog%2Futil3d

    Since you’re having issues with your algorithm it’s probably just the best solution (both to get operational faster and to learn by example not by re-inventing the wheel). If you want to do anything other than this basic kind of 3d positioning, go with a library, namely away3d.

    All the best. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any smart way to do this? If using Linq2Nhibernate , you really
Any smart way to convert a float like this: float f = 711989.98f; into
Is there any smart way to write a list comprehension over more than one
I am new in Pocket PC and Smart phone. so can any one help
Just wondering if anyone knows if there are any MSBuild starter kits out there.
There are a lot of sites out there that teach people how to build
Any smart way of doing a root based path referencing in JavaScript, just the
Was wondering if anyone had any smart approaches to creating dynamic vanity user urls
Has anyone had any experience in building a 'real world' application with the Smart
Just trying to pull off some SMART info from connected Hard Drives on any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.