Previous | Next | (P-PDF) Developers
Topic: Help with PDF based Animation?, 1 Attachments
Conf: (P-PDF) Developers, Msg: 32738
From: Jub
Date: 1/12/2002 05:13 PM
Hey Noel,
I had a look at this.
To make it a bit easier (for me) to follow I pulled everything into one doc level function, which is called from all 6 buttons.
There is then one other doc level function used to initialize the doc level variables used in the counter.
It didn't look like you needed them to be global, but you can always put them back ...
Seems to work OK.
Let me know what you think.
2 functions are below and modifed PDF attached.
Cheers,
Jub
function DocVars()
{
this.PlayButtonName = "Play";
this.StopButtonName = "Stop";
this.FirstButtonName = "First";
this.LastButtonName = "Last";
this.PrevButtonName = "Previous";
this.FwdButtonName = "Forward";
this.TheTarget = this.getField("Image");
this.cnt = 0;
this.bannerRunning = 1;
this.bannerKey = 0;
this.gIcons = new Array(4);
gIcons[0] = this.getField('Image1').buttonGetIcon();
gIcons[1] = this.getField('Image2').buttonGetIcon();
gIcons[2] = this.getField('Image3').buttonGetIcon();
gIcons[3] = this.getField('Image4').buttonGetIcon();
}
DocVars();
// calling function straight away initializes everything
function Animation()
{
var Location = event.target.name;
switch (Location)
{
case PlayButtonName :
bannerRunning = 1;
bannerKey = app.setInterval("TheTarget.buttonSetIcon(gIcons[cnt++ % 4]);",1500);
break;
case StopButtonName :
if (bannerRunning == 1)
{
app.clearInterval(bannerKey);
cnt--;
bannerRunning = 0;
}
break;
case FirstButtonName :
cnt = 0;
TheTarget.buttonSetIcon(gIcons[0]);
break;
case LastButtonName :
cnt = 3;
TheTarget.buttonSetIcon(gIcons[gIcons.length-1]);
break;
case FwdButtonName :
cnt = (cnt+1) % 4;
TheTarget.buttonSetIcon(gIcons[cnt]);
break;
case PrevButtonName :
if(cnt > 0)
{
cnt = (cnt-1) % 4;
TheTarget.buttonSetIcon(gIcons[cnt]);
}
break;
}
}
animationtest1(1).pdf
(30,529 bytes)