A nice feature in Acrobat Pro 9 is the ability to add Flash or Flex SWF files to your PDF. Potentially this could enable you to send a Flex form in PDF to one of your clients, fully interactive with charts, validators and all other Flex goodness.
Unfortunately the SWF is simply reset whenever you close the PDF or even change pages. Luckily there’s a solution. Prepare for some external interfacing with the… euh well the ExternalInterface of course.
There are two methods that you can call using the ExternalInterface to consider. The first is the multimedia_saveSettingsString. This needs your variable cast as a String to save. If you have multiple variables to save, you can use a XML-object.
The second is the multimedia_loadSettingsString which does exactly the opposite. It returns a String which you can hold in a variable, but it’s best to cast it into an XML to make it more useful.
The following is a little project demonstrating this ability. It takes the values of three fields, puts them in a XML-object and saves them whenever either of the fields change. Saving them on a change-event is safest and not taxing on performance. Simply paste the code in a new project, build, then put the SWF in a PDF (you need Acrobat Pro 9). If you fill in any field, save, close and reopen the PDF, you’ll see that the submitted fields are filled in.
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”vertical” creationComplete=”loadInput()”>
<mx:Script>
<![CDATA[
public function saveInput():void
{
var theXML:XML =
<inputForm>
<name>{nameInput.text}</name>
<firstName>{firstNameInput.text}</firstName>
<age>{ageInput.text}</age>
</inputForm>;
var result:Object = ExternalInterface.call("multimedia_saveSettingsString", theXML.toXMLString());
}
public function loadInput():void
{
var result:Object = ExternalInterface.call("multimedia_loadSettingsString");
if (result)
{
var resultXML:XML = new XML(result.toString());
nameInput.text = resultXML.name.toString();
firstNameInput.text = resultXML.firstName.toString();
ageInput.text = resultXML.age.toString();
}
}
]]>
</mx:Script>
<!–VIEW–>
<mx:Form>
<mx:FormItem label=”Name:”>
<mx:TextInput id=”nameInput” change=”saveInput()”/>
</mx:FormItem>
<mx:FormItem label=”First Name:”>
<mx:TextInput id=”firstNameInput” change=”saveInput()”/>
</mx:FormItem>
<mx:FormItem label=”Age:”>
<mx:TextInput id=”ageInput” change=”saveInput()”/>
</mx:FormItem>
</mx:Form>
</mx:Application>
The article is ver good. Write please more
Excellent article, bookmarked for future referrence