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

Calling Actionscript from 3D annotation Javascript

mcedeno101
mcedeno101's picture
Registered: Oct 15 2009
Posts: 20
Answered

I have added a Flash movie in the pdf document with a Dynamic Text and actionscript that reads;

ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript);
function receivedFromJavaScript(value:String):void {
objectSelected.objectText.text = value;
}

The objective of the movie is to dynamically display the name of the mesh from the 3D annotation (in the same page) so that the movie is called back when user triggers a “Mouse over” event on a mesh.
The movie works fine when I send a call back command thru the console.

However, when I added :
var RMA = this.getAnnotsRichMedia(0)[0];
in the script attached to the 3D annotation, so I can call back the actionscript within the Mouse Event function by saying:
RMA.callAS("sendToActionScript", modelPart[ m ].mesh.name);

Console said:
Line: 11: Code: 24(0x18): this.getAnnotsRichMedia is not a function
Line: 11: Code: 21(0x15): undefined is not an object

I tried

var RMA = doc.media.getAnnotsRichMedia(0)[0];

but still same result.

Help please.

My Product Information:
Acrobat 3D 9.1.3, Windows
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
In the script embedded in the 3D scene, "this" refers to the 3D API, not the document API - so you can't call any doc-level methods directly. Instead, you must use the 3D API's "host" object to collect a reference to the doc object:

var RMA = host.getAnnotsRichMedia(0)[0];

Note however that the returned object is not considered by the API to be a valid RMA object (it has a type of "__External_Object_Wrapper__") and events do *not* flow bidirectionally between the 3D and document APIs - anything returned by the RMA will bubble to the document level, not into the 3D script. It's partly a bug, and partly intentional (security and all), so expect to see a whole heap of warning messages in the debug console if the two annotations try to talk to each other. Some of the conversations will still work, but some won't.
mcedeno101
mcedeno101's picture
Registered: Oct 15 2009
Posts: 20
It works! Thanks! I owe you two.
:cool: