Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

timer in livecycle

Avatar

Level 3

Hi everybody

I try to get the presence of these objects when the file is opened. I use the initialize event. It works in a random way. Sometimes it's OK, sometimes it stops anywhere and sometimes it doesn't start. I assume that a pause is needed. But how can I do that.

Many thanks for your help !

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.one").presence = "visible";', 500); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.two").presence = "visible";', 1000); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.three").presence = "visible";', 1500); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.four").presence = "visible";', 2000);

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.five").presence = "visible";', 2500);  

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.six").presence = "visible";', 3000); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.seven").presence = "visible";', 3500); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.eight").presence = "visible";', 4000); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.nine").presence = "visible";', 4500); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.ten").presence = "visible";', 5000); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.eleven").presence = "visible";', 5500); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.twelve").presence = "visible";', 6000); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.thirteen").presence = "visible";', 6500); 

var Test = app.setTimeOut('xfa.resolveNode("xfa.form.ira.Page1.help_number.fourteen").presence = "visible";', 7000); 

1 Accepted Solution

Avatar

Correct answer by
Level 7

I agree with Bruce, this is likely a result of the SpiderMonkey engine doing it’s GC cycle.

At 500ms timeout, even if a local is used, it seems to work reliably. At 1000ms it works sporadically. At higher ms we can assume it won’t work at all. So the left hand side of the app.setTimeOut needs to be a global.

View solution in original post

4 Replies

Avatar

Level 10

Hi,

Maybe you can try waiting for the setTimeOut to complete before starting the next one.  This sample, https://sites.google.com/site/livecycledesignercookbooks/home/Strips.pdf?attredirects=0&d=1, tries that, so the code in the docReady event starts the first setTimeOut and then code in the layout:ready event starts the next one, with a form variable (called Count in the sample) keeping track of which subform is next.

Not sure it will scale very well, just something I thought might be worth trying.

Regards

Bruce

Avatar

Level 3

Hi Bruce,

Thanks for your answer. I download your PDF and nothing happens ? What's wrong ?

Avatar

Level 10

Hi,

I think the problem we are having is the value returned from the setTimeOut method is being garbage collected, which causes the timeout to be cancelled.  So maybe if you had a different return variable for each call to setTimeOut that would help, though event scripts (like initialize, click, docReady, etc) are not stateful so will be subject to garbage collection again, once they finish.  Maybe you could try assigning the returned value to a variable in a script object, (which should work for Reader 8.1 and later).

I have changed my sample to do something similar but I am dynamically (in the JavaScript way) creating a property on the app object, this doesn't seem to be garbage collected, or at least not as often.   Use the same link for my sample above.

Regards

Bruce

Avatar

Correct answer by
Level 7

I agree with Bruce, this is likely a result of the SpiderMonkey engine doing it’s GC cycle.

At 500ms timeout, even if a local is used, it seems to work reliably. At 1000ms it works sporadically. At higher ms we can assume it won’t work at all. So the left hand side of the app.setTimeOut needs to be a global.