My SWF Doesn’t Work When I Embed it in a PDF File…

| 4 Comments

…but it works just fine in the browser. What’s wrong?

I’ve been getting this question a lot lately as people start experimenting with Rich Media Annotations.

 

As it ends up, nothing is wrong, you’re encountering security features. Rich Media Annotations in Acrobat and Reader use an embedded Flash Player
runtime that is independent of the Adobe Flash
Player installed on the system. However, not all capabilities allowed for SWF content playing in a network
or web environment are allowed when playing inside Acrobat or
Reader. The big ones are SharedObjects, LocalConnection, FileReference and and user initiated sockets (that the restriction does not apply to RTMP streaming).

 

This white paper provides an overview
of the security model for SWF compatible content playing
inside Acrobat and Adobe Reader and describes the differences between SWF running in Acrobat and in the browser.

FLASH BUILDER 4 UPDATE

By default, new web projects created with Adobe Flash Builder 4 will use Runtime Shared Libraries in the framework linkage. This is great because it’s downloaded only once and reduces the file size of your SWF. You deploy the SWZ files along with your SWF and everything just works.

However, in a PDF file, the SWZ files need to be added as resources to the Rich Media Annotation in order for your SWF to run properly. Here’s where the problem lies. These SWZ files need to contact a server and Acrobat pops up a security dialog asking for permission.

The solution is pretty simple, you can set Flash Builder 4 to compile your project into a single SWF by selecting the Project then Properties -> Flex Build Path -> Library Path and select "Merged into code" from the "Framework linkage" drop down list… now you’ve got one SWF and no security dialogs.