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

swf pop-up

scottjan
Registered: Sep 20 2010
Posts: 4
Answered

Is there anyway I can have a Acrobat button control a swf from being visible and invisible?
 
I have a document with copy and diagrams. I would like to be able to click on the diagram and have a larger screen pop-up over the document that shows an animated version of the diagram.
 
I've been playing around with layers but it looks like with my Mac I can't import swf into a layer...only with the multimedia tool and the multimedia properties don't seem to be offer that kind of control.
 
Does anyone have any suggestions or insight?
 
Thank you

My Product Information:
Acrobat Pro 9.3.1, Macintosh
Shlomo Perets
Expert
Registered: Feb 8 2007
Posts: 18
How about the following?
.
If you set the SWF media in Acrobat so that it
... has a "in-document" setting (i.e. not floating)
... is initially disabled (until clicked or activated)
... uses an invisible poster image (e.g. 1 pixel of background color)
you can use Acrobat JavaScript in a button or link to toggle on/off the "activated" property of the media item.
.
When placing the cursor over the disabled SWF, the "Click to activate..." tool tip will be displayed. However, if you place the show/hide link over SWF media item, the tool tip will be effectively suppressed.
.
.
Shlomo Perets, http://www.microtype.com
Acrobat training & consulting

Shlomo Perets, http://www.microtype.com
Acrobat training & consulting

scottjan
Registered: Sep 20 2010
Posts: 4
That's Fantastic! Worked perfectly! Thank you very much Shlomo!
Shlomo Perets
Expert
Registered: Feb 8 2007
Posts: 18
I placed a sample file at http://www.microtype.com/showcase/MultimediaAsst/SWFpopup.pdf

To prevent the "Click to activate" tooltip, a read-only empty text field was placed over the media item.

Shlomo Perets, http://www.microtype.com
Acrobat training & consulting

scottjan
Registered: Sep 20 2010
Posts: 4
How did you get it to close? Can you take off the permissions so I can dissect it?
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
The close action is sent by the SWF - there's a mouse event assigned to the entire Flash stage, which calls Acrobat JavaScript to disable the annotation.

Note that the idea of using a text field to hide the tooltip creates a number of problems, not least with things like accessibility tools - plus if you have the object/text tool selected (the I-beam and arrow icon) then any clicks on a text field, even a read-only one, will highlight it and steal focus as Acrobat assumes you want to copy the contents. In this case you're left staring at a black box.

There are ways to move the video onto a layer (using plugins) so it works "properly", but for your purposes (as you want a real pop-up as opposed to an in-place annotation), I'd go with the floating window playback style. Draw your annotation someplace on the page but as small as possible (so you can't really see it and are unlikely to happen on the tooltip), and in the Add Flash dialog choose "play content in floating window" and specify the width and height of your SWF. Then add a link or button to your page to act as the activation tool, assign it an action of "Multimedia operations (Acrobat 9)" then choose "play" from the actions list. Despite it not being a video, asking it to "play" will activate the SWF and open the floating window.

If you really want to go to town, you can use a JavaScript action for the button, that checks if the annotation is active or not and toggles it the other way. The drawback of that is it'll only work if the user has JS enabled, whereas the "Multimedia Operation" actions work all the time.
scottjan
Registered: Sep 20 2010
Posts: 4
Thanks for the post UVSAR..Yeah I have come to the realization that the floating window would be the best way to go. I just hate that the window pops-up in the top corner and that the close button is miniscule. Unfortunately I'm a designer and not much of coder so unless I have a description of what the code does and it's already written for me, I'm useless. Speaking of....Are there any Acrobat JavaScript reference sites that have libraries of code and what it can do?
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Assuming you have only one SWF on the page, create a link or a button, and in the Actions tab, choose "Run a JavaScript" and press ADD.

In the editor that opens, paste these two lines then press OK/OK.

var rma = getAnnotsRichMedia(pageNum)[0];
rma.activated = !rma.activated;


If you want a button to target the second video or SWF on a page, change the [0] to [1], and so on. Note that on the first line "pageNum" is a real function that returns the current page number, so there's no need to change it.

There's nothing you can do about where the floating window appears in Acrobat/Reader 9 - it's always up in the top right and you can't change the border or make the close icon any bigger, but people can of course drag it about once it's opened.


The Acrobat SDK has a collection of AcroJS samples, not in the documentation but in the downloaded package - however they're not particularly exciting. If you're looking for a specific solution, aside from asking us and going through our Learning Center, you can also post a request to the Acrobat Cookbook and see if anyone's able to upload a recipe.
Shlomo Perets
Expert
Registered: Feb 8 2007
Posts: 18
I am generally in favour of media displayed in a floating window, especially when it is a "software movie" (so that there is no rescaling/downsampling resulting in degraded display).

However, for this specific application, it appears that when one clicks in the area that will be used by the floating window, the floating window sometimes opens as a blank window. This is much more noticeable when the PDF is viewed locally, less when the PDF is displayed in a browser. When the PDF is displayed in different screen or with different magnifications / page display modes, there is no way to consistently prevent this display problem.
A sample PDF which demonstrates this problem is available at:
http://www.microtype.com/showcase/MultimediaAsst/SWFpopupFloat.pdf
(the SWF file used here does not have a button to close the window when clicked)


Shlomo Perets, http://www.microtype.com
Acrobat training & consulting

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
We've not encountered that happening, and your demo file is working perfectly on our test platforms. If you wish to contact me directly with details of the actions required to reproduce the effect and of your platform, I'll take a deeper look at what might be going wrong.


On an unrelated point, I generally advise against shrinking the "dummy" RMA to effectively zero width, as we do know there are some bugs when trying to access the RMA again, for example to open the properties panel - though they won't be affecting the way it opens.
JayF
Registered: Aug 7 2010
Posts: 12
It was mentioned that there is no way to make a floating window appear, other than in the upper right, using Acrobat 9. Is it possible to set a different default position for floating windows using Acrobat X?

Jay

JayF
Registered: Aug 7 2010
Posts: 12
It was mentioned that there is no way to make a floating window appear, other than in the upper right, using Acrobat 9. Is it possible to set a different default position for floating windows using Acrobat X?

Jay

JayF
Registered: Aug 7 2010
Posts: 12
Using Shlomo's suggestion, it is easy to toggle playing and stopping the video.
With UVSAR's suggestion, using either Multimedia operations (Acrobat 9)or JavaScript, is there an easy way to toggle play and stop for the video in the floating window?

Jay

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Yes, but not with Acrobat. The floating window in Acrobat X will respect a RichMediaPosition dict object (see page 84 of the PDF1.7 EL3 specification) but we don't currently have a UI tool to apply those settings to a floating window. Until we do, you'll have to add the tags into the PDF file yourself (either using a plugin, or by editing the file directly).- edit : I've posted a sample and some information to the Ninja blog.
JayF wrote:
It was mentioned that there is no way to make a floating window appear, other than in the upper right, using Acrobat 9. Is it possible to set a different default position for floating windows using Acrobat X?
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
You can use the same JavaScript commands. Acrobat's scripting API doesn't see the floating window mode, it sees the video on the parent page.


// Code for a Play button

var rm = this.getAnnotsRichMedia(0)[0];
if (!rm.activated) rm.activated=true;
rm.callAS("multimedia_play");


// Code for a Pause button
var rm = this.getAnnotsRichMedia(0)[0];
if (rm.activated) { rm.callAS("multimedia_pause"); }



JayF wrote:
Using Shlomo's suggestion, it is easy to toggle playing and stopping the video.
With UVSAR's suggestion, using either Multimedia operations (Acrobat 9)or JavaScript, is there an easy way to toggle play and stop for the video in the floating window?
JayF
Registered: Aug 7 2010
Posts: 12
Using Shlomo's method, there is a significant delay when clicking the button to toggle the movie on and off (play and hide). Is there any way to avoid the time delay?

Jay

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Rich Media in a PDF file is stored as compressed data in a "stream" object, and when you activate the annotation, Acrobat/Reader loads the stream and decompresses it before starting playback. With a large file that can take a few seconds, and there is no way around it when the RMA is reading local content.

There can be a similar delay when deactivating a very large RMA, as a result of memory management. Again this is not something you can avoid, though Adobe are working to continually improve performance.


With Acrobat itself you cannot place an RMA into a layer, so the only way to "show/hide! the content is to activate/deactivate it. There are plugins which can transfer RMAs onto layers, but it doesn't get around the decompression delay.


JayF wrote:
Using Shlomo's method, there is a significant delay when clicking the button to toggle the movie on and off (play and hide). Is there any way to avoid the time delay?