Page 1 of 1

Difference between layer.transform.scaling and layer.scaling

Posted: February 8th, 2016, 5:16 am
by spoox
Is there any difference between accessing scaling, position and anchor points via someLayer.transform.* instead of going directly to someLayer.* ?

I had some weird case here where accessing even someLayer.transform.scale[0] would crash AE with an error about it trying to allocate several megabytes of memory, where just doing someLayer.scale[0] would work just fine.

I was doing this in an expression on a layer's .position

Re: Difference between layer.transform.scaling and layer.sca

Posted: February 8th, 2016, 5:23 am
by spoox
FWIW, how to reproduce

1. Create new comp

2. Add an image to it

3. Add this expression to the image's Transform > Position property:

Code: Select all

var me = inspect(thisLayer);

function inspect(layer)
{
    var info = {
        layer: layer,
        scaling: { x: layer.transform.scale[0] / 100, y: layer.transform.scale[1] / 100 }, // sometimes this crashes
        position: { x: layer.transform.position[0], y: layer.transform.position[1] }, // usually never crashes
        anchor: { x0: layer.transform.anchorPoint[0], y0: layer.transform.anchorPoint[1] } // this always crashes
    };

    return info;
}

transform.position;

If you remove the .transform part of the lines in inspect() it works just fine.

The reason why I started using .transform.* is because when you add an expression it usually defaults to exactly that (e.g. "transform.position")