Bryan Woods
Forum Replies Created
-
No go after testing. I also noticed it looks like there was an extra “)” after myComp.selectedLayers.length; i++. I took that out since it was first getting hung up over that. After removing that, I get a new error: “Unable to execute at line 29. Unable to call “moveAfter” because of parameter 1. undefined is not of correct type”.
Here’s the portion of my script that is handling this for your reference.
//Define project and active items
var proj = app.project;
var theComp = proj.activeItem;
var selectedLayers = theComp.selectedLayers;//Count number of selected layers
var maxIndex = -1;
for (var i = 0; i < selectedLayers.length; i++){
maxIndex = Math.max(maxIndex,selectedLayers[i].index);
}
var lastSelectedLayer = selectedLayers[maxIndex];//Create Null Object to act as controller for items
controlNull = theComp.layers.addNull();
controlNull.source.name = "Logo_Controller";
controlNull.moveAfter(lastSelectedLayer);
Thanks for your help.
EDIT:: Line 29 is referring to the line that starts with “ControlNull.moveAfter”
-
Looks like CC botched your code. Should probably be this:
var activeItem = app.project.activeItem;
var activeLayers=activeItem.layers;
for(i=1;i<=activeLayers.length;i++){
if(app.project.activeItem.layer(i).selected){
app.project.activeItem.layer(i).moveToBeginning();
};};
-
I’m curious about this too actually. Specifically, how to send a layer to the top or bottom of a comp.
-
Bryan Woods
April 1, 2013 at 8:37 pm in reply to: Adding expression via script – readability questionAaaah wonderful! MAN that makes reading the expression so much nicer. Thank you for the tip! Now I need to go back and update all my scripts with this.
-
So, are you looking down at the water from above? Thats what your linked image appears to be.
If so, I would use this expression to oscillate the scale of the layer. You could also apply it to rotation and modify it a bit to get that subtle rocking.
amp = 100;
freq = 1;
Â
s = amp*Math.sin(time*freq*Math.PI*2);
value + [s]
-
Ah, thought so. Your solution seems to work for both CS5.5 and CS6, so thank you.
I’ve never seen Number() used before though. What is that doing that fixes this for CS5.5? Is it just presenting the result within it as a number instead of as a string?
Thanks again for you help!
-
Bryan Woods
March 19, 2013 at 3:22 am in reply to: ! Script suddenly saying “Unterminated String Constant” !I figured out the problem. The issue though was the warning message wouldn’t tell me where the error was. Just a line number. But that could be referring to the script, the expression, or the text file! Very frustrating! I eventually found out it was the text file that I was pulling from. I forgot to close my quoted text while adding a new variable.
-
unless I’m missing something here, couldn’t you use AE’s built-in magnify effect instead of resorting to expressions? Would probably be faster rendering than the optics compensation…
-
Yup, thats it. Thank you Dan.
Final flicker code:
//triggers a flicker at every layer marker lasting 12framesn = 0;
duration = 12; //# of frames from marker
if (marker.numKeys > 0){
 n = marker.nearestKey(time).index;
 if (marker.key(n).time > time){
   n--;
 }
}if (n == 0){
 value;
} else {
if (timeToFrames(time) < (timeToFrames(marker.key(n).time)+duration)){
wiggle (10,90);
}else{
value;
}
} -
Hold the phone. I got it.
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}if (n == 0){
value;
} else {
if (time < (marker.key(n).time+1)){
wiggle (5,100);
}else{
value;
}
}However I’m going by timecode, and I’d like to work in frames. I know there’s a timeToFrames, but how do I work that in to this? Do I need to set time converted to frames as a variable? How do I use that with marker.key?