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

The progress bar is updated only after the end of the cycle. Help, please!

Guest
Jun 20, 2016 Jun 20, 2016

I added to the bar element, the Progressbar. It works, all is well.

One of the functions has a loop, like

for (var i=0;i<myArray.length;i++) {

myProgressBar.value = (i+1)*(100/myArray.length);

}

When the panel is opened and script is executed, the value of the progress bar is zero after the loop ends, the value of the progress bar from 100.

I also tried adding alert(""); for each iteration of the loop, then the value of the progress bar with each step of the cycle is updated. What could be wrong?

  1. Thank You!
TOPICS
Scripting
834
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
Explorer ,
Jul 17, 2017 Jul 17, 2017

Inside your loop you must call your window's update(); function to update the panel.

So if you create your window like this:

var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Panel Name", [160, 160, 10, 10]);

Your loop would look like this:

for (var i=0;i<myArray.length;i++) {

    myProgressBar.value = (i+1)*(100/myArray.length);

    myPanel.update();

}

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
Mentor ,
Jul 18, 2017 Jul 18, 2017

... and please note, that you can only update floating windows, not dockable panels. .update is a window only function. (sadly!)

But you can launch a window, while your loop is running, which as a progess bar.

Cheers,

Martin

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
Explorer ,
Jul 19, 2017 Jul 19, 2017
LATEST

Yes I discovered this after I posted. It's a peculiar restriction Adobe have imposed here.

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