FORUMS: list search recent posts

scripting 101

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sebastian Moreno
scripting 101
on May 16, 2020 at 6:33:21 pm

Hi everyone,
I am trying to get deeper into scripting but I want to improve the noob way i do it until now.
Question:

I have defined a variable --- var mycomp in a function.
then I want to use that var mycomp to do more things in a second function.
Somehow -- return mycomp; wont work. Should out it in the parameters of the second function or first? or get that var mycomp in a special way?

I know this is basic, but I would be grateful to learn this now than later.


Return to posts index

Graham Quince
Re: scripting 101
on May 17, 2020 at 4:58:20 pm

Would var localcomp = this.mycomp work?

Not used this in AE l, but when I code with JavaScript in web pages, each function is ‘closed’ and you need to use this. to view global variables.

Also return mycomp when send mycomp back to another function outside the current one.

http://www.YouTube.com/ShiveringCactus - Free FX for amateur films
http://shiveringcactus.wordpress.com/ - FX blog


Return to posts index

Tomas Bumbulevičius
Re: scripting 101
on May 18, 2020 at 7:51:07 am

Sebastian - where exactly return mycomp doesn't work? Could you share the following:
1. How do you call the function 1 in 'main area' of your script?
2. How do you defined retrieved variable from function 1?

Find out more:
Motion Graphics Design & After Effects Tutorials
On YT
On VH


Return to posts index


Walter Soyka
Re: scripting 101
on May 19, 2020 at 6:44:31 pm

This little snippet shows it in action:

function createNewComp(newCompName) {
var newCompItemObject = app.project.items.addComp(newCompName, 1920, 1080, 1, 10, 30);
return newCompItemObject;
};

function addSolidToComp(compObject) {
var newSolidLayer = compObject.layers.addSolid([0,0,0], "New Solid", compObject.width, compObject.height, compObject.pixelAspect, compObject.duration);
}

var newComp = createNewComp("Test Comp 1");
addSolidToComp(newComp);


Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

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