I think that delivering presentations could be more efficient in PDF documents than in Flash files. Once iRaccoonShow is a really usable program, it will be worth to spend some time investigating this option.

New Possibilities

Having the final presentation (and not just the slides) in a PDF document opens up new possibilities. The most important ones are:

  • Presentations will be available for all platforms where Acrobat Reader is supported. iOS and Android won’t be excluded.

  • Although I haven’t investigated this option in depth, embedded sound in Opus format may give a huge decrease in size for presentations.

These new possibilities are also important for another reason. SWFTools aren’t almost maintained at all (see their repository at GitHub). In the long run, it is also wise to investigate another options than Flash output.

Lost in Translation?

I might be wrong, but I think that the main task to get PDF presentations is to “translate” the ActionScript parts in the script that generates the Flash presentation into JavaScript for Acrobat.1

Then, it seems that I have to study again what the script that generates the Flash presentation really does and search which key components would be needed for the PDF presentation.

I hope this page doesn’t qualify as one of the worst written ones in the history of computer science. That would be such an uncertain honor, that I’d rather decline to bear so high responsibility.

What Was Available in the Past?

The analysis of the ActionScript included in the Flash presentations2 shows the following steps:

  1. Create an array for slide numbers and their starting times (line 35).

  2. Create variables for the total number of slides (line 36), the position in the timeline (line 37), the playing modes (line 38), the sound position (line 39), the total sound length (line 39) and slide showing (line 40).

  3. Create a sound object from the sound file previously embedded in the Flash presentation and (lines 53–55).

  4. Set the position at zero (line 56), the slide showing to false (line 58) and the slides number to its actual value (line 60). Populate the array with actual values for the slides and their starting times (line 61).

  5. Create a function to play and pause (line 63). Modes are stopped (or paused, as you prefer), playing and finished. The basic conditional states:
  6. Create a function to go to previous slide (line 73). It only works if the sound isn’t finished (line 74).
    • Stop sound playing (lines 75–76).
    • If position is positive, go to the starting time of the previous slide (lines 77–81).
    • Start playing sound from the new position (line 82).
  7. Create a function to go to next slide (line 86). It only works if the sound isn’t finished (line 87).
    • Stop sound playing (lines 88–89).
    • Go to the starting time of the next slide (line 90).
    • If sound position is greater than sound length, set sound position to sound length minus 500ms (lines 91–93).
    • Start playing sound from the new position (line 94).
  8. Create a function to go to first slide (line 98).
  9. Create a function to go to last slide (line 107).
    • Stop sound (line 108).
    • Set sound position to the starting time of the last slide (line 109).
    • Show the last slide (line 111).
    • Start playing sound from the new sound position (line 112).
  10. Create a function that toogles between normal and fullscreen displaying (lines 115–121).

  11. Create a function that implements double click to start playing sound or to stop it (line 123).
    • Double click is performed when there are less than 400ms (or 0.4s) between two clicks (lines 124–128).
  12. Implement function for keystrokes (lines 132–135).
  13. Create a function to check the time (which makes the whole thing work, line 157).
    • If mode is set to playing and sound position is less than 600ms to exceed the sound length (lines 158–159):
    • If mode is set to playing and sound position is more than 600ms to exceed the sound length (line 165):
      • If sound position is between the starting time of that position and the starting time of the next position (line 166):
        • If show slide is set to true (line 167):
        • If show slide is set to false (line 171):
          • If slide number is greater than the total slides (line 172):
          • If slide number is equal or less than the total slides (line 175):
            • If sound position is less than the starting time of the position (line 176):
            • If sound position is equal or greater than the starting time of the position (line 178):
  14. Set interval to check the time—the previous function—each millisecond (line 188).

  15. Set mode to playing (line 190), start sound at the begining (line 191) and add listeners for mouse (line 192) and keyboard (line 193).

    This puts the whole game in motion.

What We Might Need in the Future

Maybe I’m too optimistic (and even more ignorant), but I think that there are many similarities between ActionScript and JavaScript for Acrobat. This might make the coding of the script easier.

I think that both arrays and variables may work in a similar way in both languages. So there is no need for analysis here.

Sound handling in PDF is new to me. Only the MP3 format seems to be available in Acrobat Reader X and above versions, as sound objects.4 Multimedia objects might be a better approach, that would also allow the embedding of Opus audio.

Final Afterthought

I have just added a postscript.

Notes

  1. Adobe has two main documents that deal with JavaScript for Acrobat:

    The former is an introduction with examples, and the latter contains a complete catalog of objects, properties and methods.

    Since this is much a trial and error for me, I will take notes about the use of JavaScript for Acrobat in this page

  2. From the script that generate the presentations, the ActionScript is contained between the opening .action: and its matching .end tag, which are lines from 35 to 193

  3. For some reason unknown to me, this doesn’t work with Firefox 60. I was experiencing it with previous versions. Once set to normal mode, Firefox doesn’t seem to be able to set the display to fullscreen again.

    Fullscreen display works fine with Midori

  4. According to http://kb2.adobe.com/cps/405/kb405848.html, but I don’t know how current this information is. With multimedia objects, Opus audio depends on the player.