开发者

ActionScript Measuring 3D Depth

开发者 https://www.devze.com 2023-01-02 06:10 出处:网络
i\'m having a difficult time understanding how to control the z property of display objects in a 3D space.i know how depth works, but what i don\'t understand is how i can get the maximum depth, or th

i'm having a difficult time understanding how to control the z property of display objects in a 3D space. i know how depth works, but what i don't understand is how i can get the maximum depth, or the number at which the display object just disappears into the background.

i assume depth is based on the stage's width and height, and that is why assigning the same depth of the same display object appars 开发者_JAVA百科mismatched with different stage sizes.

so how can i appropriately measure depth?


You need to consider the childIndex property. There is no Z-index in actionscript.

To get the depth you could use:

// returns the number of direct display children in stage
stage.numChildren; 

// returns the number of direct display children in you object
myObj.numChildren; 

To set the child Z-index use

//sets the newIndex of child in stage
stage.setChildIndex(child:DisplayObject, newIndex:int):void; 

If newIndex is 0 then child is top visible element.

newIndex must be in [0, numChildren-1] else flash will throw errors

Take care.


As of Flash 10, there is a 'z' property.

Checkout this link for a tutorial: http://www.kirupa.com/developer/as3/intro_3d_as3_pg1.htm


it's explained here: Perspective in Flash

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号