Copy link to clipboard
Copied
Greetings all,
I have been tasked with making an interactive map for a learning exercise course. This only needs to be a map base graphic with some icons simulating different modes of transportation (i.e. - trucks, trains, planes), different building types and so on). The participants just need to take a scenario and determine the most effective way to get resources A to destination B by collecting there icons and drag them around on the map until they figure a solution.
All I need to do is just have the icons CLICK and DRAGABLE...the problem is, IT CANNOT BE FLASH-BASED...argh! This is extremely easy to do in Animate but the Flash Player is required to display the SWF file in the PDF...which as I said, is not an option.
The client has requested a PDF and I'm hoping I can deliver...does anybody have add a CLICK and DRAG code snippet for objects in Acrobat?
And just in case you're wondering, I haven't asked if I can give them an EXE file...which would solve all of my problems...but EXE files are pretty much outlawed and probably not good to ask until I have exhausted every possibility.
Thanks all...I have all my fingers and toes crossed on this one!
Copy link to clipboard
Copied
The Acrobat JavaScript model does not include click and drag functionality, but it does include enough functionality to create an effective click and drag.
There are two main tricks to doing this.
1. Create a page sized transparent button to capture mouse clicks.
a) when the button is clicked, get the mouse coordinates with the doc.mouseX and doc.mouseY properties,
b) and then look though the annotation list for the page to see if any of the graphics, which I'm assuming are stamp annots, match the click position
2. On detecting a mouse down on a graphic, start an interval timer (app.setInterval).
a) This timer runs a function that captures the mouse position and moves the selected graphic annotation the same distance the mouse has moved since the mouse down.
b) When the mouse up is detected, kill the interval timer.
And that's how its done. It gets more complicated if you want to detect when the user changes pages. I've dealt with this before by using a different interval timer to watch for page changes and then move the button to the new page.
Copy link to clipboard
Copied
Thanks for the reply, Thom...I must say your answer reads well but I think it might be a bit over my head. The good thing is, it will only be a ONE page PDF...just the map with all of the movable icons.
I'll put my thinking cap on and give your instructions a shot...
Is there any way you can create a PDF with the page sized transparent button with one-two movable items that I can study?
Again, thanks.
Copy link to clipboard
Copied
You can download a sample here that uses a very similar technique, only it's not page size buttons.
Download and examine the "Swat the Fly" game.
Free Sample PDF Files with scripts
Copy link to clipboard
Copied
Thank you, Thom, I'll take a look at it and let you know how it goes.
Copy link to clipboard
Copied
Thom,
This is way more complicated than what I need...which makes it practically impossible for me grasp. Thanks for the effort...I'll just have to see what I might be able to figure out from your original response.
Copy link to clipboard
Copied
If you are still looking then ....
It to create a button field and to allow the reader of the PDF document to move the button field using JavaScript and the Acrobat/JavaScript API. "Clicking and Moving a Button Field in PDF" includes an example with two fields that you can drag around. It also includes the JavasScript function (constructor) to realize this feature. You may also want to consier developing an authoring tool that would generate the draggable button automatically.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more