Hi there,
I am having difficulty getting a javascript function to execute when a button in the SWF is clicked.
The following is my actionscript code trying to call the Javascript function defined in the PDF.
addEventListener(MouseEvent.CLICK, function(e:MouseEvent) { ExternalInterface.call("eval","bob()"); g2_btn.x += 2; });
Where bob() is document level defined javascript function which simple prints to the console
//<Document-Level> //<ACRO_source>bob</ACRO_source> //<ACRO_script> /*********** belongs to: Document-Level:bob ***********/ function bob() { console.println("BOB"); } //</ACRO_script> //</Document-Level>
Is there something that i am missing?
Or is the above only possible in version 9 of Acrobat
Any ideas / help would be appreciated
ExternalInterface.call( "bob" );
If you want to have any arguments, just pass them as additional arguments to the call method. Such as:
ExternalInterface.call( "hello", "Bob", 2 );
With the Acrobat document-level JavaScript here:
function hello( name, times )
{
if ( name && times )
for ( var i = 0; i < times; i++ )
console.println( "Hello, " + name + "!" );
}
- grayson [at] adobe [dot] com