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

Easy question, but it's driving me batty...ACK!

thegoblinking
Registered: Aug 6 2010
Posts: 10
Answered

I'm not sure if this is the appropriate place to ask, but then again I'm not exactly sure where my problem is...I know it's a ridiculously easy problem to fix, but I just haven't seen it yet.

~ OK, the background:

I'm learning how build a rich media PDF. I'm building the most basic pdf i can with a simple Flash button to advance the page. I'm missing something very basic because I can't get it to work.

~ The goal:

I simply want to understand the interaction between AS3 and Javascript, get the most simple example of it working that I can make, and then learn/build/play from there.

~ The files/elements:

A simple 10 page pdf, exported from InDesign cs4, that is totally blank save for simple page numbers manually inserted via text fields.

A plain flash button, consisting of nothing more than a rectangular primitive, converted to a movie clip, with some simple AS3 in it. No up/over/down states involved or called for, just a simple box with no animation whatsoever.

~ The API...and I'm guessing my problem:

OK, the Flash 'button' is embedded in the pdf itself via the Flash Media tool, and the code is as follows...

Flash AS3 -

function fClick(e:MouseEvent):void
{
ExternalInterface.call("turnNext");
}

redsquare.addEventListener(MouseEvent.CLICK,fClick);

And the JavaScript that receives that command sits at the document level and reads -

function turnNext()
{this.pageNum++;
}

I open it in either Acrobat or Reader, the pages advance manually via the menu bar just fine...but if I click that Flash button? The taskbar indicates the page number advanced to page 2, the page itself never leaves page 1 though (like it gets hung up mid page-turn), the whole thing freezes and boots the Acrobat or Reader right on the spot.

I can't see how I could make it more simple, and yet I'm still missing it. The code itself 'this.pageNum++;' works fine in the Javascript Debugger, advances the pages as it should...I don't get it. What am I missing?

I'd be eternally grateful if someone would point out what I'm sure is a simple oversight on this!

Thank you VERY much...LM

“Courage is going from failure to failure without losing enthusiasm.”

~ Winston Churchill

thegoblinking
Registered: Aug 6 2010
Posts: 10
It's kind of crazy...I mean, the Flash code must work otherwise the JavaScript couldn't 'hear' the command and wouldn't even TRY to turn the page...and it tries.

The JavaScript works fine in the JavaScript Debugger, and it's sitting at the document level where it can 'hear' the AS3.0 pass it a command.

There are literally no other elements in the entire thing to interfere with it...heck, I've only got the button on one page. I'm only trying to turn it to page 2 and leave it at that.

Is it some kind of global setting for the pdf that I missed?

/compared to this, running a reactor on an aircraft carrier was EASY...

“Courage is going from failure to failure without losing enthusiasm.”

~ Winston Churchill

thegoblinking
Registered: Aug 6 2010
Posts: 10
In retrospect, it seems like the simpler I made it, the closer Acrobat got to making it work...like the code needed extra time to work itself out, and the more time it had (ie, the simpler it got) the closer it got to working.

Maybe a timer stuck in there somehow might give it the breathing room it needs? But...where?

After the actual command comes in from the Flash button, but before the Javascript executes?

Like:

Flash Button Pressed -> ExternalInterface.call("turnNext"); gets issued, then(insert time for Flash button to finish)

and then the JavaScript executes...

function turnNext()
{this.pageNum++;
}

Does that make sense?

If it does, then I guess the timer would be inside the 'turnNext' JavaScript function, and it'd count to 'X' and then issue the this.pageNum++; command...does that make sense?

If so...darn, how do I do a timer?


"Success is going from failure to failure without losing enthusiasm" ~~ Winston Churchill

“Courage is going from failure to failure without losing enthusiasm.”

~ Winston Churchill

thegoblinking
Registered: Aug 6 2010
Posts: 10
I GOT IT!!!!!!!!!!!!

Thanks to studying postings by Mr.'s Geraci and Corey (threads referenced at the end of this, I got it!!

The solution that worked for me was to simply load the JavaScript into the button itself in Flash AS3...no work needed on the Acrobat side:

The AS3 that works...a Flash page navigation button that increments to the next page after a time delay (here, I used a half second):


function fClick(e:MouseEvent):void
{
ExternalInterface.call( "eval", "app.setTimeOut('pageNum++;',500);");
}

redsquare.addEventListener(MouseEvent.CLICK,fClick);



The referenced threads:

http://acrobatusers.com/forums/aucbb/viewtopic.php?pid=37372
http://blogs.adobe.com/pdfdevjunkie/2008/09/how_do_you_close_a_floating_ri.php

This finally stopped my pdf from crashing....YAY!!!

I'll post this in the Rich Media section for reference, for the next poor N00B bastard (like me!) who has to figure this out...

ANCHORS AWEIGH!!!!!

“Courage is going from failure to failure without losing enthusiasm.”

~ Winston Churchill