Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to set value from a slidercontrol in a UI?

Participant ,
Sep 19, 2017 Sep 19, 2017
Hello,
Could someone help me to control a property with a slider in a UI?

I'm using a UI dockable template from "David Torno", and using rd. Gimme Prop Path, as Tomas Sinukas teach me earlier...
but I can not seem to get the UI slider to control the Slider of my Text Tracking property.

I'm trying to follow all "Torno's" tutorials step by step, but I can not seem to find how to enable the return of the slider value to change my Property.

What the hell am I doing wrong?

Thank for all adobe community!
ps. Sorry my bad english.



// I have only one  TEXT layer in my Comp, with a Tracking Animator inside text properties//
//  here is the script I'm trying to use //

{

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'],\

                              myStaticText: StaticText{text:'StaticText Text'},\

                              myEditText: EditText{text:'EditText text'},\

                              myButton: Button{text:'Button Name'},\

                              myCheckbox: Checkbox{text:'Checkbox Name'},\

                              myRadioButton: RadioButton{text:'RadioButton Name'},\

                              myDropDownList: DropDownList{properties:{items:['Item 1 Name', 'Item 2 Name', 'Item 3 Name', 'Item 4 Name']}},\

                              myListBox: ListBox{properties:{items:['Item 1 Name', 'Item 2 Name', 'Item 3 Name', 'Item 4 Name']}},\

                              mySlider: Slider{text:'my slider', value:500, minvalue:0, maxvalue:1000},\

                              mySliderValue: StaticText{text:'mySlider', },\

                              myGroup: Group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\

                                        myGroupItem1: Button{text:'Hi'},\

                                        myGroupItem2: Button{text:'Hello'},\

                                        myGroupItem3: Button{text:'Goodbye'},\

                              },\

                              myPanel: Panel{text:'Panel Name', orientation:'column', alignChildren:['right', 'fill'],\

                                        myPanelItem1: Button{text:'One'},\

                                        myPanelItem2: Button{text:'Two'},\

                                        myPanelItem3: Button{text:'Three'},\

                              },\

                              myTabbedPanel: Panel{type:'tabbedpanel', text:'Tabbed Panel Name', orientation:'column', alignChildren:['right', 'fill'],\

                                  myTab1: Panel{type:'tab', text:'Tab 1', orientation:'column', alignChildren:['right', 'center'],\

                                      aButton1: Button{text:'Button1'},\

                                  },\

                                  myTab2: Panel{type:'tab', text:'Tab 2', orientation:'column', alignChildren:['left', 'center'],\

                                      aButton2: Button{text:'Button2'},\

                                  },\

                                                                      },\

                              myProgressBar: Progressbar{text:'Progressbar Name', minvalue:0, maxvalue:100, value:50},\

                    }"

                

                    //Add resource string to panel

                    myPanel.grp = myPanel.add(res);

                    // controllers

                   

                    var trackingTextSrc = app.project.item(1).layer(1).property("ADBE Text Properties").property("ADBE Text Animators").property(1).property("ADBE Text Animator Properties").property("ADBE Text Tracking Amount").value;

                    var sld1 = myPanel.grp.mySlider;

                   

                    // onClickEvents

                   

                    sld1.onClick =  function(){

                   

                    trackingTextSrc.setValue(sld1) ;

                    }

                    // DropDownList default selection

                    myPanel.grp.myDropDownList.selection = 2;//Item index starts at 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);

}


TOPICS
Scripting
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Sep 19, 2017 Sep 19, 2017

This is rather simple:

slider.onChange = function () {

  var trackingTextSrc = app.project.item(1).layer(1).property("ADBE Text Properties").property("ADBE Text Animators").property(1).property("ADBE Text Animator Properties").property("ADBE Text Tracking Amount");

  trackingTextSrc.setValue(slider.value);

}

First off, you have to listen to onChange event. I don't think sliders have onClick event anyways.

Once you catch this event, you can get that tracking property the way you have done now and then

...
Translate
Advocate ,
Sep 19, 2017 Sep 19, 2017

This is rather simple:

slider.onChange = function () {

  var trackingTextSrc = app.project.item(1).layer(1).property("ADBE Text Properties").property("ADBE Text Animators").property(1).property("ADBE Text Animator Properties").property("ADBE Text Tracking Amount");

  trackingTextSrc.setValue(slider.value);

}

First off, you have to listen to onChange event. I don't think sliders have onClick event anyways.

Once you catch this event, you can get that tracking property the way you have done now and then feed sliders value to that tracking property. Easy peasy.

Since you are probably just starting out scripting, start by giving proper names to variables - slider makes more sense then sldr1;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 19, 2017 Sep 19, 2017
LATEST

I had never found anything about "onChange", Thank you very much for your help ... it worked perfectly!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines