I've got a Flex based swf file embedded as a Flash object in PDF. It has to be clicked for activation, causing it to open as a large floating window.
The swf has an "OK" button which initiates an interaction with the PDF. What I am trying to achieve its that the floating window is automatically closed, and the swf inactivated again, after the interaction is complete. So far I can only achieve this by selecting "Disable Content" in the context menu (which becomes available when the "Disable When" setting is set to such in the Flash object properties). I would like this action to be included in the script that is executed in the Flex button.
Is there perhaps a JavaScript that can achieve this (which could in turn be called by ActionScript in the Flex button)?
Many thanks.
Now for the diffucult part. Closing the floating player from a button on the SWF. The problem is that when the SWF ActionScript calls a JavaScript functon, the Flash player waits for a response from Acrobat JavaScript. If the call closes the Flash player then all heck breaks loose and Acrobat hangs or crashes. The trick is to decouple the actions with a timout script. I've been trying to figure this one out for a while and this solutions was just provided to me today by Joel Geraci, the Acrobat Technical Evangelist.
Use this line of code from the close button in the SWF
ExternalInterface.call("eval","app.setTimeOut('this.getAnnotRichMedia(this.pageNum,\"RM0\").activated=false;',100);");
The setTimeOut fucntion returns right away so the player is happy. Then the deactivation happens outside the context of the call for the RichMedia, making Acrobat happy.
Make sure you get all the quotes right, and the Annot name right. I've got this set up in one of my examples so that when the Rich media annot is setup, it finds it's own name and page number. Then sets them as persistent values. That way nothing needs to be hard coded in the SWF and it can be used on any PDF by just copying the RichMedia annot from one PDF to another.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script