These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Javascript in swf

Anonymous
Answered

Hi all,
 
I have several flash files embedded inside a PDF. There is a button in the swf file that i would like to either hide a layer or a button from within the PDF file. I believe i have to use the ExternalInterface.call(); method and I have added the relevant code/import statements in the flash file, the thing i am struggling with is how to add the Javascript inside the parenthesis.
 
The code below will hide the field in the PDF if it is executed in Acrobat, but when i add it in Flash is throws 3 error messages up!!
 
function goNow(e:Event):void{
gotoAndPlay(16);
ExternalInterface.call(var remov = this.getField("remov");
remov.display = display.hidden;);
}
 
Am i missing anything or is the code incorrect?
 
Any help would be greatly appreciated

My Product Information:
Acrobat Pro 9.3.1, Macintosh
ekschperte
Registered: Jun 12 2010
Posts: 29
There are two ways to achieve a Flash(ActionScript) - PDF(JavaScript)-communication:
a) With callback functions

// The flash AS function triggered by an event
public function goNow():void
{
var myArgument = "test";
ExternalInterface.call("fromAS_myCallback", myArgument);
}// The corresponding JS callback function
function fromAS_myCallback(argMyArgument)
{
// do anything
}b) With eval

// A flash AS function which increments the current pdf page
public function nextPdfPage():void
{
ExternalInterface.call("eval","app.setTimeOut('this.pageNum++;',250);");
}
smitchell15 (not verified)
Thank you very much for your help, i've got it working.
Watched a brilliant tech talk from Dave Merchant and together i've learnt a lot. Thank you very much
Cheers :-)