Expand my Community achievements bar.

SOLVED

Change fontColor with app.setTimeOut

Avatar

Level 2

Hello

Sorry for my english.

I want change the fontColor of a field more than one time.

I have in event click of a field this:

app.setTimeOut( 'field.fontColor = "128,128,128"' , 2000);

but without luck...

anybody knows?

Thanks,

Luis.

app.setTimeOut( 'field.fontColor = "0,0,0"' , 4000);

app.setTimeOut( 'field.fontColor = "128,128,128"' , 6000);

app.setTimeOut( 'field.fontColor = "0,0,0"' , 8000);

app.setTimeOut( 'field.fontColor = "128,128,128"' , 8000);

1 Accepted Solution

Avatar

Correct answer by
Level 8

Ya you have to use app.setInterval. app.setTimeOut just occurs once.

Here's your code:

global.myTimer =

app.setInterval("myXFAObject = xfa.resolveNode('"+TextField1.somExpression+"');"+ //Change TextField1 to yours

    "if (myXFAObject.fontColor=='0,0,0') myXFAObject.fontColor='128,128,128';"+

    "else myXFAObject.fontColor='0,0,0';",500);//500 milisecond intervals

As a rule of thumb, anything you put in quotes for your JavaScript for app.setInterval or app.setTimeOut is in the context of the Acrobat API and not the XFA processor. A good way to determine if your code will work is to bring up the console and type it in there. If it works in the console, it should work in your timer.

And to stop the flashing:

app.clearInterval(global.myTimer);

Kyle

View solution in original post

4 Replies

Avatar

Level 8

Do you mean you want the font colour to flash??

I'm just wondering why you would want to use app.setTimeOut?

Kyle

Avatar

Level 2

Hi Kyle,

Yes that is.

I don't know other way, do you know change the color as flash with other way?

ZAMPAZAMPA

Avatar

Correct answer by
Level 8

Ya you have to use app.setInterval. app.setTimeOut just occurs once.

Here's your code:

global.myTimer =

app.setInterval("myXFAObject = xfa.resolveNode('"+TextField1.somExpression+"');"+ //Change TextField1 to yours

    "if (myXFAObject.fontColor=='0,0,0') myXFAObject.fontColor='128,128,128';"+

    "else myXFAObject.fontColor='0,0,0';",500);//500 milisecond intervals

As a rule of thumb, anything you put in quotes for your JavaScript for app.setInterval or app.setTimeOut is in the context of the Acrobat API and not the XFA processor. A good way to determine if your code will work is to bring up the console and type it in there. If it works in the console, it should work in your timer.

And to stop the flashing:

app.clearInterval(global.myTimer);

Kyle

Avatar

Level 2

Thanks Kyle. Worked perfectly!

ZAMPAZAMPA