These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Flash links when embedded in PDF pages - possible?

rtidd
Registered: Mar 31 2009
Posts: 12
Answered

I need to have my head examined. But..

I have a flash (swf) file that has a couple links on it.
It works great on a webpage. I'd like to take those links and keep them active when I
embedd that swf in a pdf page.

I know the PDF can either have PDF page navigation or URL navigation links when created with Acrobat.
I can't simplify the problem and make the whole swf area a single PDF invisible link
as I would loose some of the interactive properties (clicking) of the flash itself.

For simplicity lets assume I have a 4 page PDF
PDF page 2 has a small swf on it that has two clickable links on it.
In an ideal world the first swf link would launch a browser window to the specified URL,
the second link would goto page X of the PDF.

Nothing like cutting your teeth creating 'interesting' projects!
Can it be done? If so how?

With the exception of links I have a working flash flipping book catalog in a pdf.
So that means.. Start with an image. (or pdf if you have an older version of flash)
Make it into a single page flash (swf) to be able to add roll over effects and links.
This single page swf will be loaded by the flip book catalog swf.
Take that catalog swf and insert it into a new PDF...
This flipping book swf utilizes resources (the page swfs and xml file describing the catalog)
so use the Resources tab in the Advanced options section of the Insert Flash Dialog to add them to the PDF.

It's insane. It works GREAT. But if that flip book was on say page 2 of the pdf file, and I either wanted
the innermost swf file to navigate to page 4 of that pdf file or bring up a browser URL.....

I have actually been able to take a flash photo gallery and get it to run inside a pdf. Ya, I know.. WHY? But I CAN.
All the gallery nav buttons, music, voice overs, and stuff work great. I am only having a problem with links to places
outside of the inserted flash object. They appear to be disabled by the containing PDF.

I know that flash can pass messages outside itself, like DB data lookups via AJAX or SOAP,
so maybe the answer lies in a form of message passing going to Adobe's scripting (Javascript) language?

Thanks.
--Ron--

My Product Information:
Acrobat Pro Extended 9.1, Windows
joshcorey
Registered: Jul 14 2008
Posts: 79
Hi Ron,

without spending a lot of time answering today I will give you a few quick pointers you may be able to proceed with...

To navigate to a page in the PDF you will use actionscript to make a call to Acrobat javascript to go to the page you desire... I have not played much with Acrobat javascript but I am positive you can accomplish this. You may want to look at this posting if you run into a problem when Acrobat navigates to the other page:
http://blogs.adobe.com/pdfdevjunkie/2008/09/how_do_you_close_a_floating_ri.php

To navigate to a URL in the browser you will encounter the Flash security dialog asking you to OK the link due to the Flash/Acrobat security model, but it works fine. In your SWF you can use NavigateToURL, getURL, URLRequest etc to navigate to an URL. Make sure the publish settings are set to "Local access only" and it should work fine, I do it all the time with every type of AS3 call I know to launch a URL.
rtidd
Registered: Mar 31 2009
Posts: 12
GOT IT..
Unfortunately may not help as the flipping book code I have is pretty old. But. My test works great!.
the http://acrobatusers.com/tutorials/2008/08/js_flash_buttons/ link helped immensely.

I created a new flash file, and put 2 rectangular movie clips on it.
I attached MouseEvents to them for MouseEvent.CLICK
The first event listener had these 2 lines of code:
var request:URLRequest = new URLRequest("http://www.acrobatusers.com");
navigateToURL(request);

The second event listener had this line of code:
ExternalInterface.call("foo", "ButtonTwo!");

These were included in the class definitions for flash and compiled to make a swf file.

Using the flash tool, I added the swf to a blank page PDF.
I then used the menu Advanced->Document Processing->Document Javascripts...
and added a new script name of foo
it is as follows..
function foo(myParm)
{
app.alert(myParm, 3);
}

and when saved and opened in Reader 9 the 2 button clicks work great, one asking for permission to open the URL,
and the second popping up an alert window. I guess looking up the goto page javascript command should be trivial at this point.

Not sure what I'll do now with the old flash files, I suppose changing the links on the swf resources would be easy enough but if the resources included by the old flipping book swf work remains to be seen in testing.

Thanks.
This site rocks!
--Ron--
rtidd
Registered: Mar 31 2009
Posts: 12
Ah well.
For me no joy..

My flipping book swf code is a few years old now, and since it uses OLD actionscript, the page I created as a test does
not work when added to the catalog, or even display.. The OLD swf file doesn't like the new AS3 file. I should have remembered that. I'll report back if I find a happy solution.
rtidd
Registered: Mar 31 2009
Posts: 12
VICTORY IS MINE!

Scenario..
I have one of those flash flipping book thingies I need to put inside a PDF, the page navigation links on the flash app need to work.
The encapsulation of objects looks like this: PDF->Flip Book swf->PAGE swf.To make matters worse the Flip Book App I have is several years old and it won't load AS3 pages in from it's config file.

HOW I FIXED IT.
After several tries to get an updated flip book swf, with NO response I used a decompiler (Sothink SWF decompiler) to create a flash source file (.fla). I purchased both the finished swf and mxp for this app back when it was very cheap and liberal with it's licensing, and all updates were supposed to be free so I don't think I'm breaking any copyright stuff here. (I am very happy with the flipping book ap itself btw.)

I needed to keep AS2 compatibility on my individual pages used in the flip book, to make the book work so that was my obstacle. I could keep the links on the page .swf that went to webpages as they worked for me. The Actionscript for web links (AS2 style) is : getURL("http://some.website.com");

Since I also need links to send me to specific places in the outer PDF I need to use the ExternalInterface.call function in Actionscript, but the page .swf is nested inside a book .swf and that caused me issues. Trying to use ExternalInterface.call to the outer .swf and then relay it gave me no joy. BUT.. Simpler yet, if I add a simple function to the topmost .swf in it's main timeline I got it to work...

The Page .swf code:
_root.doExternalInterfaceCall("somefunction", "somedata");

The outermost .swf (AS2 remember...) then has the definition for that function:
import flash.external.*;
function doExternalInterfaceCall(myfncall, parm)
{
flash.external.ExternalInterface.call(myfncall,parm);
}


I actually think that the flash.external. in that command is redundant, but it works so I'm leaving it alone.

With this I can use any function in the outer PDF that I wish to define without messing with that flipping book .swf again.
In the example I am going to define Adobe Javascript function for somefunction(somedata);

So inside Acrobat Pro Extended:
Advanced->Document Processing->Document Javascripts
Script Name = somefunction
Click on Add

To goto a specific page number was easy: (obviously somedata would be a page number in the page .swf code)
function somefunction(somedata)
{
pageNum = somedata;
}


But that sucks if you add pages / delete pages / or reorder pages.
a better solution is to create named targets.
VIEW->Navigation Panels->Destinations
Then use the select tool to click on the target and click the target icon in the destinations dialog.
then rename the target to "somedata" or whatever text label you wish to use in the page .swf

Finally create the Javascript function to go to the named target.
function somefunction(somedata)
{
this.gotoNamedDest(somedata);
}


In my code I have actionscript for the page like this : _root.doExternalInterfaceCall("gotoTarget", "rontest");
with a named target of "rontest" in the PDF, and a Javascript function:
function gotoTarget(name)
{
this.gotoNamedDest(name);
}


Hope that helps someone else with similar headaches. :)
joshcorey
Registered: Jul 14 2008
Posts: 79
Great, I am glad you were able to solve your problem. Thank you for posting your results/steps so that it may help out the rest of us.
borisV
Registered: Dec 8 2009
Posts: 3
Thank you for the information. I was wondering how to make this because I want to use it on my PDF price list. I will try it!

http://www.imextra.eu

dungxvn
Registered: Dec 22 2009
Posts: 1
Thank you very much, I had the same question too and now I have the solution.

http://skitech.org/gardenmachines

phyllis01
Registered: Dec 10 2009
Posts: 1
Surprising! Maybe I can have some experiment too embedding flash on a pdf page. Thanks a lot for the information.
Graemezee
Registered: Apr 18 2010
Posts: 2
Hi Totally new Actionscripitng 3 in Flash, have done some javascripting and adobe acrobat have spent the weekend trying to replicate this. Can some one point me in the correct direction

Flash CS4

import flash.events.MouseEvent;

myButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
ExternalInterfaceCall("gotoTarget", "rontest");
}function gotoTarget(name)
{
this.gotoNamedDest(name);
}Error message
1180: Call to a possibly undefined method ExternalInterfaceCall.

Adobe Acrobat Scripts

aInit

if(app.viewerVersion < 9)
app.alert("This file requires Acrobat/Reader 9 for the Flash buttons to operate",1);


somefunction

function somefunction(somedata)
{
this.gotoNamedDest(somedata);
}
Graemezee
Registered: Apr 18 2010
Posts: 2
Through trial and error have got CS4 and Acrobat have got the ExternalInterface.call("DisplayPopup","Hello"); Button working

Extrapolated CS4 element based on what worked previously for DisplayPopup

import flash.events.MouseEvent;
import flash.external.ExternalInterface;

myButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
ExternalInterface.call("gotoTarget", "rontest");
}

my Acrobat PDF Script

function gotoTarget(name)
{
this.gotoNamedDest(name);
}

This Crashes Acrobat any thoughts
nassamba
Registered: Jul 24 2010
Posts: 1
I want to embed a browser into a pdf. The browser should open as a popup window on the same page with no tool bar. The browser should open when a button is clicked on the pdf. A JavaScript code which could do this well be fine.
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Cannot be done. We don't want people using chromeless browser windows to fake application dialogs.

nassamba wrote:
I want to embed a browser into a pdf. The browser should open as a popup window on the same page with no tool bar. The browser should open when a button is clicked on the pdf. A JavaScript code which could do this well be fine.