views:

28

answers:

1

I have a class named Box that extends Sprite and when I'm trying to access his transform.matrix3D property (indeed is the matrix3D property from an Transform object) this returns me null. Why?

package some.place
{
    // ... imports ...

    public class Box extends Sprite
    {
        public function Box() {}

        public function DoSomething():void
        {
            var m:Matrix3D = transform.matrix3D;
            // here m == null !!! Why???
        }
    }
}
+2  A: 

By default 2D object have no matrix3D, i.e. if you have not use any 3D stuff (z property, rotationY,etc ...) with your DisplayObject you will have a null matrix.

N.B. You can also set the matrix3D to null to reset back you object in 2D

The value of the z property of a 2D object is zero and the value of its matrix3D property is null.

Patrick
As a quick note, the easiest way to ensure you have a non-null matrix3D property (without otherwise affecting the view of your DisplayObject) is to just set the `displayObjectInstance.z = 1;`.
Sly_cardinal