Expand my Community achievements bar.

SOLVED

Timer Not Working

Avatar

Level 2

Hi

I am trying to call a function from a timer using the following code:

var mTimer;
function testTimer()
{
mTimer = app.setInterval( "runTimer()", 1000 );
}

function runTimer()
{
app.clearInterval(mTimer);
app.alert("timer run");
}

The function runTimer() simply doesn't run.

The only way I can get the timer to work is with a line like this:

mTimer = app.setInterval( "app.alert('test')", 1000 );

However, calling a function doesn't work.  The code is in a global module.  It doesn't work with anything I try, such as:

mTimer = app.setInterval( "Global.runTimer()", 1000 );

I am using a Dynamic XML form in Designer 9 (trial version).

Many thanks

Geoff Olding

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

This is not going to be easy to explain but you are mixing object models. The command app.asetInterval is an Acrobat command based on the AcroForm Model. The Global.runTimer() function is an function written against the xfa model. Acroform objects donot know about XFA objects so your synatx wil be incorrect. To be able to call that function you will need the associated Acroform name. Here is a sample to show you The code is on the click event of the button.

Paul

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

This is not going to be easy to explain but you are mixing object models. The command app.asetInterval is an Acrobat command based on the AcroForm Model. The Global.runTimer() function is an function written against the xfa model. Acroform objects donot know about XFA objects so your synatx wil be incorrect. To be able to call that function you will need the associated Acroform name. Here is a sample to show you The code is on the click event of the button.

Paul

Avatar

Level 3

You are geniues man hhhhh You helped me as will but I have one problem which the running timer will stop after 10 seconds why is that ?

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----