Enabling Commenting of SWF content in Acrobat 9

| No Comments

The Basics of SWF in PDF
One of the great new features of Adobe Acrobat 9 Pro and Pro Extended is the ability to add interactive SWF content developed in Flash or Flex. SWF files can be placed in a PDF using the new Flash Tool in Acrobat 9 and play using the built in Acrobat 9 Flash Player rather than the external one that your browser and desktop use. The built-in player provides greater security and consistency for SWF playback inside any PDF with that type of content. For those of you that attempted to use SWF in earlier versions of Acrobat, you remember that the user experience wasn’t all that great. Acrobat 9 provides tight integration between the PDF document and SWF as well as other content types that run in the Flash Player such as FLV and H.264 encoded video.

Read “Add multimedia files to a PDF” to learn how to add SWF content to PDF files using the new Rich Media Annotation rather than the legacy multimedia object.

There are two ways to play the SWF widget or in Acrobat, on the page or in a floating window. The floating window has certain advantages when you need the SWF to be present regardless of what page you are on in the PDF. However, when the SWF is played on the page, you are able to use the Acrobat commenting features to review and markup the interactive content.

Review and Markup SWF content using Acrobat 9
By default and no additional coding in the SWF, you can add a comment to any SWF content placed on a PDF page. When another user wants to review your feedback by clicking on your comment in the “Comments” navigation panel, a bitmap of the state of the SFW content at the time the comment was made will be displayed with your markup sitting on top. This alone can help speed up designer/developer workflows even if the ultimate destination of the SWF is a web page and not a PDF.

But… with just a little coding, we can take things a huge step further.
In addition to the built-in Flash player providing greater security and consistency for SWF playback, it also has built in functions that take advantage of features found only in Acrobat and Reader. The remainder of this article discusses just two of those functions but there are more, stay tuned for future articles.

Storing the state of your SWF when a user adds a comment
Acrobat sends your SWF content a “multimedia_getState” callback when a user adds a comment. Your job is to collect up all the variables you need to get back to this state into a single string. When you return this string from the function called by the “multimedia_getState” callback, Acrobat will store the string in the annotation’s properties.  In the attached code sample, I’m simply storing the content of the text field. For more complex applications, I recommend using an XML object to store the variables and then casting it to a string before returning it. You’d then cast it back to XML when you need to restore the state.

Restoring the state of your SWF when a user clicks on a comment in the “Comments” navigation panel
When a user selects a comment from the “Comments” navigation panel that belongs to your SWF content, Acrobat sends your SWF a “multimedia_setState” callback along with the string that was passed to Acrobat when the comment was made. Your job is to take the information in the string and use it to set the variables you need in order to restore the state that the SWF was in when the comment was created. By default, the initial representation is still the bitmap that I referred to above but when you click back into the SWF content, you’ll see that the variables are all restored to what they were (assuming you set them back correctly from the string).

Take a look at the attached sample Flex application to see how this works. You’ll see that I’m adding callbacks for “multimedia_getState” and “multimedia_setState” in my creationComplete() function. The rest is basic Flex code.

The PDF example already has some comments in it and is Reader extended for commenting so if you just have Reader 9, you can still see how this works.

Example PDF

Sample Flex Application