FORUMS: list search recent posts

After Effects Sripting - create cycle by loop

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marcel Legindi
After Effects Sripting - create cycle by loop
on Feb 1, 2017 at 2:26:33 pm

Hello all JS guru´s I would like to find a way how to build ui by loop. I created many buttons by loop and I dont know how to call their own function. Buttons are in array.. but when i click on some of them there are on .onClick function.
I need give function to every button and .onClick must bu functional ... i dont know how.


Let me explain this concrete:

I have code:


var mainWin = new Window ("palette","Lip Sync",undefined);
var groupOne = mainWin.add("group",undefined,"grupa jedna");
groupOne.add("statictext", undefined, "XXX");

var groupTwo = mainWin.add("panel", undefined, "yyy");
groupTwo.orientation = "row";
var but =[];
for (var i = 1 ; i<= 6; i++)
{

but[i] =groupTwo.add("button", [undefined,undefined,100+i,100], "buut" + " " + i );
but[i].onClick = function ()

{
alert ("button ID...show [i] somehow");/// there i need somethink to remember button ID

}


}
alert (but[3].size); //controll alert for button number

mainWin.show();


Return to posts index

Dan Ebberts
Re: After Effects Sripting - create cycle by loop
on Feb 1, 2017 at 6:27:55 pm

Using this.text in your function should allow you to differentiate between the buttons:

alert (this.text);

I think you can also give each button a name and use this.name.

I'm not sure if that's what you're asking.

Dan



Return to posts index

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