View comments | RSS feed

After Effects CS3  |  Go to CS4 Help

Layer General attributes and methods

width
Return type: Number.

Returns the width of the layer, in pixels. It is the same as source.width.

height
Return type: Number.

Returns the height of the layer, in pixels. It is the same as source.height.

index
Return type: Number.

Returns the index number of the layer in the composition.

parent
Return type: Layer, Light, or Camera.

Returns the parent Layer object of the layer, if there is one. Example: position[0] + parent.width

hasParent
Return type: Boolean.

Returns true if the layer has a parent or false if it doesn’t.

Use the hasParent attribute to determine if a layer has a parent. You can use this attribute even if there isn’t a parent layer at present. For example, the following expression indicates that the layer to which you apply it will wiggle based on the position of the layer’s parent. If the layer has no parent, then it will wiggle based on its own position. If the layer is given a parent later, then the layer’s behavior will change accordingly:

  idx = index; 
  if (hasParent) { 
    idx = parent.index; 
  } 
  thisComp.layer(idx).position.wiggle(5,20)

inPoint
Return type: Number.

Returns the In point of the layer, in seconds.

Note: In general, the value of outPoint is greater than the value of inPoint. However, if a layer is reversed in time, the value of inPoint is greater than the value of outPoint. Similarly, the value of startTime can be greater than the value of inPoint.

outPoint
Return type: Number.

Returns the Out point of the layer, in seconds.

startTime
Return type: Number.

Returns the start time of the layer, in seconds.

hasVideo
Return type: Boolean.

Returns true if the layer has video, or false if it doesn’t.

hasAudio
Return type: Boolean.

Returns true if the layer has audio or false if it doesn’t.

active
Return type: Boolean.

Returns true if the layer’s Video switch  is on and the current time is between the layer’s In point and Out point; false otherwise.

audioActive
Return type: Boolean.

Returns true if the layer’s Audio switch  is on and the current time is between the layer’s In point and Out point; false otherwise.

sampleImage(point, radius = [.5, .5], postEffect=true, t=time)
Return type: Array [4].

Argument type: point is an Array [2], radius is an Array [2], postEffect is a Boolean, and t is a Number.

Samples the color and alpha channel values of a layer and returns the average alpha-weighted value of the pixels within the specified distance of the point as an array: [red, green, blue, alpha]. If postEffect is true, the sampled values are for the layer after masks and effects on that layer have been rendered; if postEffect is false, the sampled values are for the layer before masks and effects have been rendered. The input value point is in layer space; the point [0,0] is the center of the top-left pixel in the layer. The input value radius specifies the horizontal and vertical distance from the sample center to the edges of the sampled rectangle. The default value samples one pixel.
Note: The postEffect parameter refers to effects applied directly to the layer, not to effects applied indirectly, such as with an adjustment layer.

This example samples a rectangle 4 pixels wide and 3 pixels high, centered around a point 100 pixels down and to the right of the upper-left corner of the layer:

  thisComp.layer(1).sampleImage([100, 100], [2, 1.5])

Dan Ebberts has an example of how to use the sampleImage method on his website: www.adobe.com/go/learn_ae_danobscuration.


Comments

Comments are no longer accepted for After Effects CS3. After Effects CS4 is the current version. To discuss After Effects CS3, please use the Adobe forum.

Comments


Todd_Kopriva said on Feb 20, 2008 at 8:21 AM :
Some folks on the AE Enhancers website have created an expression using the sampleImage method that measures text layers and shape layers, accomplishing a result similar to using the scripting method sourceRectAtTime:
http://www.aenhancers.com/viewtopic.php?f=6&t=931

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/en_US/AfterEffects/8.0/WS3878526689cb91655866c1103906c6dea-7a00.html