What script to create a model with a user interface panel

Hello guys,.

So I am new to scripting and javascript and I'm trying to keep it simple. I'm a VJ and want to create a script where I get a 'BPM' and a 'beat' lengh and it generate me a comp with the right length and * a layer with a marker ofr each beat.

I was able to create this script, but I try to make it look a little better with integration of the user interface for AE I wasn't able to make it work right. If anyone can help me or give me some advice. I think that I'm not good with the expression "addComp" in the buildUI function.

I copy everythin because it is long but you'll be understaind the main idea. My question is how to that the entry in my Advanced UI instead of "the guest".

Here is my first code that does the job:

Elements Var Set

var name = prompt ("membership name");

var BPM = prompt ("your BPM");

If (isNaN (BPM)) {}

Alert ("you must give the model a value");

}

Var prompt = beats ("how many times");

If (isNaN (Beats)) {}

Alert ("you must give the model a value");

}

frameRate var = prompt ("your fps");

If (isNaN (frameRate)) {}

Alert ("you must give the model a value");

}

term var = (60 / BPM * bat); Automatically generated

var beat = (60 / BPM);

Part of creation

app.project.items.addComp (name, 1920, 1080, 1, duration, frameRate); Create the model with custom Lengh

App.Project.Item (01).layers.addSolid ([0,0,0], "BG", 1920, 1080, 1, length); Create solid BG

var firstLayer = app.project.item (1) .layer (1);

firstLayer.label = 16;

App.Project.Item (01).layers.addSolid ([0,0,0], "FX", 1920, 1080, 1, length); Create sound FX

App.Project.Item (01).layers.addNull (Duration); Create the Null object

var firstLayer = app.project.item (1) .layer (1); Rename the Null object

firstLayer.enabled = false;

firstLayer.name = "Beats";

firstLayer.label = 0;

Place a marker on the 64 first beat

var myMarker = new MarkerValue("0");

firstLayer.property("Marker").setValueAtTime (beat * 0, myMarker);

Every beat on opacity-keys

myProperty = firstLayer.opacity;

myProperty.setValueAtTime (beat * 0, 0);


For reference, I'm going to place code Dan here and use line numbers, as I explained.

Fig. A

var name = prompt("Composition name");
var BPM =prompt("Your BPM");
if (isNaN(BPM)) {
    alert("You must give the comp a value");
  }

var Beats = prompt("How Many Beat");
if (isNaN(Beats)) {
    alert("You must give the comp a value");
    }

var frameRate = prompt("Your fps");
if (isNaN(frameRate)) {
    alert("You must give the comp a value");
    }

var duration = ( 60  / BPM * Beats ); //Auto Generated
var beat = (60  / BPM);
//Creation Part
var myComp = app.project.items.addComp(name, 1920, 1080, 1, duration, frameRate); // Create Comp with Custom Lengh
var firstLayer = myComp.layers.addSolid([0,0,0], "BG", 1920, 1080, 1, duration); // Create BG Solid
firstLayer.label = 16;
myComp.layers.addSolid([0,0,0], "FX", 1920, 1080, 1, duration); // Create FX Solid
firstLayer = myComp.layers.addNull(duration); // Create Null Object
firstLayer.enabled = false;
firstLayer.name = "Beats";
firstLayer.label = 0;
// Place a marker on the 64 first beat
var myMarker = new MarkerValue("0");
firstLayer.property("Marker").setValueAtTime(beat*0, myMarker);
// Key every Beat on opacity
var myProperty = firstLayer.opacity;
myProperty.setValueAtTime(beat*0, 0);

OK, so for your configuration, looks like you're striking four data sets. You have the model name (fig.) At line 1), BPM (lines 2-5 of Fig. (A), (lines 7-10 of Fig. rhythms (A) and the FPS (lines 12 to 15 of Fig. (A). then it comes to the UI, you can change what I had posted to...

res = "group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
  myCompName: EditText{text:'Enter comp name'},\
  myBPM: EditText{text:'Enter BPM'},\
  myBeats: EditText{text:'Enter beats'},\
  myFPS: DropDownList{properties:{items:['23.976', '24', '29.97', '30', '59.97', '60']}},\
  createComp: Button{text:'Create comp'},\
}"

This will give you all entries in four data for the user interface. It is preferable to assign each control to a new variable for use in your script.

// Control Variables
  var compName = myPanel.grp.myCompName;
  var myBPM = myPanel.grp.myBPM;
  var myBeats = myPanel.grp.myBeats;
  var fps = myPanel.grp.myFPS;
  var createComp = myPanel.grp.createComp;

Once you have these variables you can then start the default implementation as appropriate. in this case, the drop-down list should be a starting point for it's selection, so that you can say to use the first default entry as follows.

//Defaults
  fps.selection = 0;

Now, you can configure your onClick for button createComp feature. This will contain to working part of the Dan code that treats everything (lines 17-33 of Fig. (A). I've added a few lines of options above this (lines B Fig. 1-7) in the below code just to match the variable names so you wouldn't need to change the code.

Fig. B

//onClick setups
  createComp.onClick = function(){
  //Gather user entered values
  var name = compName.text;
  var BPM = Number(myBPM.text);
  var Beats = Number(myBeats.text);
  var frameRate = fps.selection.text;

  var duration = ( 60  / BPM * Beats );
  var beat = (60  / BPM);
  //Creation Part
  var myComp = app.project.items.addComp(name, 1920, 1080, 1, duration, frameRate);
  var firstLayer = myComp.layers.addSolid([0,0,0], "BG", 1920, 1080, 1, duration);
  firstLayer.label = 16;
  myComp.layers.addSolid([0,0,0], "FX", 1920, 1080, 1, duration);
  firstLayer = myComp.layers.addNull(duration);
  firstLayer.enabled = false;
  firstLayer.name = "Beats";
  firstLayer.label = 0;
  // Place a marker on the 64 first beat
  var myMarker = new MarkerValue("0");
  firstLayer.property("Marker").setValueAtTime(beat*0, myMarker);
  // Key every Beat on opacity
  var myProperty = firstLayer.opacity;
  myProperty.setValueAtTime(beat*0, 0);
  }

Then line 2 Fig. b starts the call onClick for button and assigns a function. Within the function, we run the process. Fig. B Line 4 seizes the compName edit text attribute of the text control, using the Number() function convert us this text to a number for use online B Fig. 9 and 10 and B Fig. 5 line gets the text attribute of the text control edit BPM. Goes same for line 6 of the Fig. B and the beats variable. For line B Fig. 7, a drop-down list requires calling his selection of the attribute, then it is text attribute to get the actual string. The drop was more logical for FPS due to the standard rates that exist. This list can be changed of course to your liking. Now, there is no safety net as I like to call for the modification of the text controls to make sure text is not entered when you need a number and vice versa. It would be something of can check after line 7, Fig. B before trying to run the code in process (Fig. B lines 9-25). I hope that it will be easy enough for you to understand.

If the script is as follows.

{
function myScript(thisObj) {
  function myScript_buildUI(thisObj) {
  var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Panel Name", [0, 0, 300, 300]);

  res="group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
  myCompName: EditText{text:'Enter comp name'},\
  myBPM: EditText{text:'Enter BPM'},\
  myBeats: EditText{text:'Enter beats'},\
  myFPS: DropDownList{properties:{items:['23.976', '24', '29.97', '30', '59.97', '60']}},\
  createComp: Button{text:'Create comp'},\
  }"

  //Add resource string to panel
  myPanel.grp = myPanel.add(res);

  // Control Variables
  var compName = myPanel.grp.myCompName;
  var myBPM = myPanel.grp.myBPM;
  var myBeats = myPanel.grp.myBeats;
  var fps = myPanel.grp.myFPS;
  var createComp = myPanel.grp.createComp;

  //Defaults
  fps.selection = 0;

  //onClick setups
  createComp.onClick = function(){
  //Gather user entered values
  var name = compName.text;
  var BPM = Number(myBPM.text);
  var Beats = Number(myBeats.text);
  var frameRate = fps.selection.text;

  var duration = ( 60  / BPM * Beats );
  var beat = (60  / BPM);

  //Creation Part
  var myComp = app.project.items.addComp(name, 1920, 1080, 1, duration, frameRate);
  var firstLayer = myComp.layers.addSolid([0,0,0], "BG", 1920, 1080, 1, duration);
  firstLayer.label = 16;
  myComp.layers.addSolid([0,0,0], "FX", 1920, 1080, 1, duration);
  firstLayer = myComp.layers.addNull(duration);
  firstLayer.enabled = false;
  firstLayer.name = "Beats";
  firstLayer.label = 0;

  // Place a marker on the 64 first beat
  var myMarker = new MarkerValue("0");
  firstLayer.property("Marker").setValueAtTime(beat*0, myMarker);
  // Key every Beat on opacity
  var myProperty = firstLayer.opacity;
  myProperty.setValueAtTime(beat*0, 0);
  }

  //Setup panel sizing and make panel resizable
  myPanel.layout.layout(true);
  myPanel.grp.minimumSize = myPanel.grp.size;
  myPanel.layout.resize();
  myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

  return myPanel;
  }

  var myScriptPal = myScript_buildUI(thisObj);

  if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
  myScriptPal.center();
  myScriptPal.show();
  }
  }

  myScript(this);
}

Tags: After Effects

Similar Questions

  • Deal with the user interface panel in differenet C code

    http://digital.NI.com/public.nsf/allkb/1D8F1B4E8B1C6FB0862576880033C69A

    This KB is matched with my question. But the download link is not valid. Can someone give me an example? Thank you very much.

    The link is not valid due to a revision of site that changed paths. The correct link is this one.

    I posted a comment on this page, request correction.

  • Interact with the user interface components

    I'm trying to find a GOOD way to interact with the external classes user interface components. For example, that you have a 'controller' class that needs to access the view of the user interface in some way (define a label text or something else). The controller class does not do anything, it discusses only the logic of what should be the case. Currently, it is created by my top-level class when the program starts. He listens to some events occur and needs to update/interact with the user interface or the State of the application depending on what events are. I do not seem to be a way for this controller class to easily access the UI component that I need to get my hands on.

    I'm trying to do to reduce the size of a file of mxml WindowedApplication growing (LOOK cool but that is not important) and take part of the logic of the application of this file.

    It's complicated by the fact that the label is in a State that does not have the status of 'base' (so it is not a child, or even a subsidiary child of the main class at boot time) and by the fact that it is not yet near a high school component. (If that were the case, I could probably just pass the label object in the constructor for the outdoor classroom.)

    In other words, I can't just call getChild ("labelName") on my 'main' request object because it is buried nested inside OTHER components. I don't think I like the idea to browse all components and sous-composants recursively looking for the component that my outer class trying to ask. I thought about other ideas, but I don't like any of them enough to try them, eh.

    I'm at the point now about where I come to the conclusion that my fundamental design strategy is wrong, or Flex just not allowing complex applications where the GUI components can interact with external classes relatively pain-free. I'm not convinced that "Flex cannot do', I'm looking for advice on some great Flex application in all design patterns.

    Where do you put this kind of control logic, and what happens when it starts to overflow and become so large that you need to break in other files?

    Found a solution, I think that's what I've been looking for:

    http://labs.Adobe.com/wiki/index.php/Cairngorm

  • How can we create a document in the user interface?

    Hi all

    Is there an API to create a document in the user interface? Please help me...

    Oh, I you you now. This is something that was queried on before but most often to get the glimpse of another program. You can get an overview of the current document, open but I don't think that there is an exposed method for a document not open. Obviously, I has this ability, but unfortunately it's not in the API, at least that I've ever seen.

  • What is with the user interface?

    Hi all

    Just downloaded PSE8 to see if I want to spend the PSE6. Not really sure yet. For openers you can't empty the 'welcome' screen and the choices are, you are going to get what you want or not. Now for the 'UI adjustment' in preferences > general tab. Well you can do 'light '. I do like it, it's not as light as my old PSE5. I could never understand why Adobe went to a black user interface? However, when you do the 'light' UI, all the necessary buttons ie. file, edit, improve, layer, etc. are so dark you can't find them, let alone read them. It is sort of like hit or miss. I think the buttons should display a white lettering when you change the UI to light. You know, just so that you can find, either that or make the buttons in braille. Well that's my rant and PSE8 question. Why programmers can't think of anything like that?

    John

    It is not that they are not - they reminded a lot of people with previous versions. But they seem not to care, unfortunately. If you want to be sure adobe reads your thoughts, use the comments tab on the Contact link at the top of this Web page to tell them. Since this is a user to user forum, there is no knowing for sure that someone from adobe will see to what you post here.

  • Is it possible to add a hard drive to a VM running via a script or a program without using the user interface

    I'll try to ask this question clearly, but I ask that read you it carefully, because I can't do a great job of setting out clearly what I'm looking for.

    I know how to create a virtual disk in a batch file or a script.  I know how to have a running virtual machine to detect a newly added hard drive and format it in Linux, BACK, and NetWare. I do not have scripted this part, but I did it manually by adding records via the UI and then by doing the steps manually to make the operating system to detect and format the newly added drive. In each case, these steps are scriptable with the exception of the addition of the drive in the user interface.

    The only way I know to add a new hard disk to a virtual computer running is through the user interface. I don't know in a way that can contain script (for example vmrun or an API call) to make.

    I guess that maybe I can have the virtual machine to go into sleep mode and then add the HDD in the vmx file while the machine is in standby mode, then put the computer to sleep mode, although I have not tested this.

    My question is, ' can a virtual drive be added to a virtual machine running without using the user interface and without put the machine to sleep, or in other words in a script any?

    Have you tried VI SDK?

  • createTextField() will not work with the user interface component

    I use ActionScript to create a TextField and it works very well.

    If I then add (button or checkbox) user interface component to the stage of the textfield stops displaying.

    If I remove just the button on the stage of the object TextField does not always display. If I then remove the button component symbol in my library, TextField appear again!

    Here's the script. It works as long as there is no UI component in the library.

    See Code attached. Displays text, it will stop the display if you put a button on the stage.


    Thanks for any help

    MRC06460CT

    Hello

    I thought I had fixed this problem, but you are right. If I put the arguments in the correct order, the text does not go far.

    Thank you very much

    Mike Cohen

  • Need a script to create standard vSwitch with virtual and several computer port group VLAN

    I want to create standard vSwitch for all hosts in the cluster for virtual machine port group and add one or more groups of ports VLAN for the same standard vswitch.

    Kind regards

    Shan

    Try something like this

    $clusterName = "mycluster.

    $nics = "vmnic0", "vmnic1.

    $vlans = 123456789

    foreach ($esx in (Get-Cluster-name $clusterName |)) Get - VMHost)) {}

    $sw = New - VirtualSwitch - name swX - VMHost $esx - Nic $nics - confirm: $false

    $vlans | %{

    New-VirtualPortGroup-name "PG $($_)" - VLanId $_ - VirtualSwitch $sw - confirm: $false

    }

    }

  • view script that creates a view of another user

    How can I see the script for a view?

    Thank you

    From sqlplus do following:
    set pages 0
    the value of 10000 long
    Select dbms_metadata.get_ddl ('SEE', 'Nom_de_vue') of double;

  • You are KILLING ME with the user interface layers

    Why did you move it out of the range of main tools and to the top of the page so I have to hunt for him?

    Why you place it between even designed icons that I hit by mistake whenever I want to move the layer?

    Why do you continue to hide the submenu layers, creating an extra tap to reveal it and slowing down that's me down even more?

    Why you repeat the same menu once for each layer, 10 TIMES, instead of ONCE for all the layers palette, they way it is in ideas?

    The great thing about this app that it can be used as a digital tracing paper pad - sketch and change the opacity of each layer that you refine and position elements in different places. Why do make it it more difficult to take advantage of this feature?

    Hi Don,.

    Thanks for your comments. We moved the layer icon because for some reason many people do not see here where he was. (I'm curious to know what icon you are misunderstanding the layers icon. The share icon? "It will help to know if I can convey this information).

    On the submenu layers (and it's the repetition in each layer): even though this is the first time I've seen comments about its repetition, we receive frequent requests to move somewhere that is accessible with a single click. I don't know what the plan is for it, but I will certainly share your comments passionate with the draw for the team.

    We are pleased that you find useful application. And very happy that you use frequently. Please know with certainty that it is not our goal is to make things difficult.

    Thanks again for taking the time to post.

    Sue.

  • Problems with the user interface button

    I know it's a simple enough question, but do not understand the error myself.

    The problem is that the "Reading license" button does not run the alert("");

    I have tried all the ways, I know, but can't seem to understand.

    Is there something that I missed?

    Create window

    hwin var = new window ('dialogue', "Help and settings", undefined);

    hrs var = ' group {orientation: 'column', alignment: ["fill", "fill"] alignChildren: ["fill", "fill"],-}.

    groupOne: group {orientation: 'column', alignment: ["fill", "fill"] alignChildren: ["fill", "fill"],------}

    bannerImage: Image {text: 'Image', image :'/ C/Program Files/Adobe/Adobe After Effects CS6/Support Files/Scripts/ScriptUI Panels/Layer_tools Icons/Banner.jpg'},\}

    Subject: StaticText {text: ", properties: {multiline: true}}, \

    helpImg: Image {text: 'Image', image :'/ C/Program Files/Adobe/Adobe After Effects CS6/Support Files/Scripts/ScriptUI Panels/Layer_tools Icons/Description.png'},\}

    },\

    groupTwo: group {orientation: 'row', alignment: ["fill", "fill"] alignChildren: ["fill", "fill"],------}

    ccLicens: button {text: 'Reading license', preferredSize: [75,25], alignment: ['right', 'Center']},

    okButton: button {text: 'OK', preferredSize: [75,25], alignment: ['right', 'Center']},

    },\

    }";

    hwin. GRP = hwin.add (HRS);

    All text:

    hwin.grp.groupOne.about.text = 'name ' +.

    ' \nCreated by: © copyright 2013 +.

    "\n\nLorem ipsum dolor sit amet, adipiscing elit computer." +

    "\n\nLorem ipsum dolor sit amet."

    OK button

    OK var = hwin.grp.groupTwo.okButton;

    Ok. Onclick = function()

    {

    hwin. Close();

    };

    Play button of license:

    var readLicense = hwin.grp.groupTwo.ccLicens;

    readLicense.Onclick = function()

    {

    Alert ("Something");

    };

    Display 'Help and settings' victory

    hwin. GRP. Layout.Layout (true);

    hwin. Center();

    hwin. Show();

    Quentin

    Should be "onClick".

    readLicense.onClick = function() {}

    Alert ("Something");

    };

  • Is there an add-on that has the page with a user interface, just the content. Same view F11, but in a minimized state

    I use the always on the top of the page Add on and minimizes a window for watching videos while doing other things.
    But the Web bar and the tab bar allows plenty of space, so I was wondering if someone knows a plugin that will hide all the UI and simply let the content, something like view full-screen, presing F11, but in a reduced state.

    Thank you

    Try to use this extension.
    https://addons.Mozilla.org/en-us/Firefox/addon/custom-geometry/

    When you set up this extension, you will need to play with the Options through the add-on Manager tab and adjust the width, height, left and Top according to your needs. If you do not have a huge super resolution monitor default settings in CG will place the Firefox window on the right side of the screen.

    Once you get all of these parameters, move the toolbar toolbar button. When you press F11 this window will go into mode full screen expanded, then move the slider to the top of the screen to reveal the toolbars and click on the custom button geometry to restore your custom window size and position. Then this window snap into place and the toolbars will hide again. YMMV

    Note: Custom geometry has never been [IMO] adequate updated for Firefox 4 and the drop-down toolbar button does not work and adds it to the width of the toolbar button.

  • I can't interact with the user interface. For each click, it lags for like 2 seconds!

    Hello

    I just bought the new MacBook Pro with Retina Display Mid 2015

    2, 8 GHz Intel Core i7

    16 GB OF RAM

    AMD Radeon R9 M370X

    AE v. 13.5.1

    I installed CC applications as usual and everything was fine until today. Ive been using before AE with this new computer and everything worked smoothly.

    Nothing has changed in terms of parameters or updates. He just started lagging. I can't use it because its boring. Whenever I click on something it is lagging! This also happens when there is no open compositions, just the app and the im through the settings.

    IM new to this forum so I hope someone can help!

    If you need a form more just say.

    Thank you very much!

    I've seen a number of people with questions on these forums with images keys do not release when you release the mouse and other weird things - almost always when a Wacom tablet has been installed. The problem persists even if the Tablet is disconnected.

    I wonder if your problem is.

  • problem with the user interface

    Hello

    I want to store a LabelField and a ButtonField in unique horizontalFieldmanager.

    display aside and left to the right of the label button.

    I was able to view a horizontalField but I want to display as below then how it is possible.

    Text1 button1

    Button2 Text2

    Text3 button3

    Code:

    for (int i = 0; i)<>

    {

    HorizontalFieldManager hfm5 = new HorizontalFieldManager()
    {
    protected void sublayout (int width, int height)
    {
    Field field;
    get the total number of areas falling under this Manager of
    int numberOfFields = getFieldCount();
                   
    System.out.println ("length =" + numberOfFields);
    int x = 0;
    int y = 0;
    for (int i = 0; i)<>
    {
    field = getField (i); get the field
    System.out.println (i + "->" + field);
    setPositionChild(field,x,y);
    layoutChild (field, width, height);
    x += 130;
    }
    setExtent (width, height);
    }
    };

    hfm5. Add (Text);

    hfm5. Add (Button);

    }

    Please help me as soon as possible:

    code above show me data only once.

    example:

    Text1 button1

    Hello

    Thanks for help me.

    I solved problem myself.

  • Help me with my user interface Simple Design

    HI everyone I'm new to BB development...

    So I want to develop a simple application... When everything works except user interface design...

    The problem is the following

    My Ui should have two tabs or (buttons... addbutton and ListButton) where after clicking on the first button

    the content of the "addButton" must appear for example. labelfIELD, CHEXKbOXfIELD, button...

    And AFTER, by clicking ON THE "ListButton" it should display the content of the "ListButton" button for example.

    LabelField and editField in a horizontal way... and all by posting the content of the button eachg the

    content of the dedicated back button should be deleted...

    Please help me I need very urgent...

    And if possible send me a link through which I can easily learn from user interface design and plants athe Ui using "Threads".

    Thank you

    Sharath

    The first place I'd start is the sticky post on this forum:

    http://supportforums.BlackBerry.com/T5/Java-development/useful-links-for-novice-and-experienced-Prog...

    Then I would go to video library where you can 'see' how the UI code, but it was certainly a little more:

    http://NA.BlackBerry.com/eng/developers/resources/VideoLibrary.jsp#tab_ddetail_subtab_jde

    Last but not least:

    http://www.thinkingblackberry.com/archives/category/UI

    Now regarding your problem of button, you can do an add() and remove() to switch your two fields to emulate a tab container or use the following example:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/How_To_-_Create_tabbed_view_screens.htm...

Maybe you are looking for

  • Import bookmarks from Safari 5.1.7

    Hello. I would like to import all my bookmarks from Safari to Firefox/Mozilla 5.1.7. I have over 200 of them and I'd like to avoid having to go to each site to rebook (mark) it. I'm on the following equipment: Model name: iMacModel identifier: iMac8,

  • Toshiba L5 TV Remote "not available".

    Hey,. My TV do not react in the remote control. I can't turn it off, I have to unplug my TV whenever I want to turn it off. Whenever I press something on my 'not available' message remote appears on the screen, nothing works. It happened after runnin

  • Snow Leopard 10.6.8

    On my great desktop iMac now about 3 years I was happy until very recently, using gmail, and Apple mail. I chose to not pass beyond OS x 10.6.8 because this OSX allows me to use my Stylewriter venerable and faithful for printing: and I still have a d

  • Extraction of documents on a USB?

    Wrongly, I recorded my changes to a document and ended up deleting 30 pages, argh!  Is it possible to recover the original please? It's on my USB key. I found dates back-up and updated the, etc. on the computer, but not for the USB key. I would be gr

  • Standard USB Host Controller 43 error code

    Original title: Code 43, w/PnP problems? Microsoft has disabled my backup storage device (he called unknown device) because these problems have been detected. Standard USB host controller. I need to access the files stored there. How can I access fil