FORUMS: list search recent posts

Reference to it self in other comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hannes Paulsson
Reference to it self in other comp
on Sep 5, 2011 at 3:33:10 pm

Ok, this might be a bit hard for me to explain since english isn't my first language, but I'll try.

Here's the situation. I have a comp with 250 precomps in it, lined up so the whole comp is opaque. In all of these precomps there's a 3d-box (simple box made i AE).

The thing is that I want to rotate them at a random time 360 degrees on the y-axis, and when they hit 270 degrees I want the visible side of the 3d-box to change.

What I've done is to make to layers in each precomp with this expression on one of them:
a=comp("Zoom-comp").layer("H2").transform.yRotation
if (a<=270) 100 else 0

And this on the other:
a=comp("Zoom-comp").layer("H2").transform.yRotation
if (a>=270) 100 else 0


The thing is that if I do it this way, I have to rewrite the code 512 times, on for each layer in each precomp. Så basically what I'm looking for is an expression that replace the ".layer("H2")" with something that always points to itself, so I can write the expression only once and then just duplicate the precomp.

Thanks alot!
Hannes


Return to posts index

Dan Ebberts
Re: Reference to it self in other comp
on Sep 5, 2011 at 8:53:02 pm

Are all the cubes instances of the same precomp, or are they all independent objects in the project panel?

Dan



Return to posts index

Hannes Paulsson
Re: Reference to it self in other comp
on Sep 5, 2011 at 10:55:10 pm

Right now they are all independent objects in the project panel, but if its possible it would be better to be able to have only one and have instances of that precomp.


Return to posts index


Dan Ebberts
Re: Reference to it self in other comp
on Sep 5, 2011 at 11:05:30 pm

If you want them to behave independently, you'll want to leave them as separate objects. Are the sides of the cube parented to a null at the center? If so, why not just have each null rotate at a random time?

Dan



Return to posts index

Hannes Paulsson
Re: Reference to it self in other comp
on Sep 6, 2011 at 9:36:04 am

Ah, sorry, of course they should be different comps, I dont know what i was thinking.

So I have 256 individual precomps, and I want to be able to rewrite the expression from the first one (called H1 in the previous expression), so that I can use the exact same expression for all different comps. Is this at all possible?


Return to posts index

Dan Ebberts
Re: Reference to it self in other comp
on Sep 6, 2011 at 12:33:49 pm

If you were to rewrite it for another comp, how would it be different?

Dan



Return to posts index


Hannes Paulsson
Re: Reference to it self in other comp
on Sep 6, 2011 at 12:59:45 pm

I would have to change the comp-name the expression refers to, in this case "H1" to the name of each individual precomps name. So the next one would be "H2", and so on.

But I don't think I'm gonna use this method, had to come up with another way of doing it any ways. But it would still be nice to know if this is possible or not.


Return to posts index

Dan Ebberts
Re: Reference to it self in other comp
on Sep 6, 2011 at 1:15:15 pm

I would think you could do it if the name of the layer in the other comp were related in some way to the name of the comp with the expression. How are the comps named, and is there a one-to-one relationship?

For example, if the expression in comp A2 needs to refer to layer H2 in comp "Zoom-comp", you could do something like this:

a=comp("Zoom-comp").layer("H"+thisComp.name.substr(1)").transform.yRotation



Dan



Return to posts index

Hannes Paulsson
Re: Reference to it self in other comp
on Sep 6, 2011 at 2:45:35 pm

Ah, okay. I want the precom "H1" to relate to itself in the zoom-comp, and this seemd to do the trick!

a=comp("Zoom-comp").layer(thisComp.name).transform.yRotation
if (a<=270) 100 else 0


Thank's Dan! Helpful as always!

All the best
Hannes


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]