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

Array as a parameter by "callAS"-method (JavaScript/ActionScript Bridge)

floG23
Registered: Apr 21 2010
Posts: 14

Hi,
 
Is there a possibility to set an array as a parameter in the rma.callAS Function? I tried it the last hours, but i didn´t get it to work.
 
Code in JS:
RMAs = this.getAnnotsRichMedia(0)
for each (RMA in RMAs)
{
RMA.callAS("updateList", _array);
}
  
Callback-Method in RMA:
ExternalInterface.addCallback("updateList", updateList);
 
Methode:
private function updateList(_array:Array) : void
{
...
}
 
Why isn´t it working? :(
 
Maybe you have some helping words for me.
 
Greetings
floG24

My Product Information:
Acrobat Pro Extended 9.4, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
What is in the array? I believe that only generic parameters can passed.

What is received on the ActionScript side?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

floG23
Registered: Apr 21 2010
Posts: 14
I want to update the dataProvider of mx:List via another RMA in my pdf. So the array looks like:

array = [{label: "label1", data: 0}. {label_ "label2":, data: 1}....]

I realized the tutorial of Joel Garcia (http://pdfdevjunkie.host.adobe.com/RMA3_RMA2RMA.shtml) and changed his content to mine.

So i made a String in ActionScript side, which i tunnel with the "eval" function. So the string seems to be "defined" in Javascript.

My functions work with string and integer as parameter in my callAS-method. But not with an array :(

On the ActionScript side, the function, which i call does not accept my parameter and does not fill out this path.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So what is received on the ActionScript side? Is the input argument null? is it an array of null parameters? is the function called at all?

Have you tried passing an array of simple integers or strings? It may be that the problem is not the array, but the objects in the array.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
JavaScript does not have an "associative array" - they're objects, not members of the Array class, so the declared type for your function doesn't match. Unless it does, the ExternalInterface layer will not call the function.
floG23
Registered: Apr 21 2010
Posts: 14
Maybe i can try to call the array by a String? So on Actionscript side, i have to kill the quotationmarks through a function? These "sentences" i can set into an array...Is this possible?

Many thanks for your fast answers! You made my day better cause i became desperate last day :/
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
No, you can pass the data as an "array" just fine, but just declare your variable as an "Object" in AS3:


in AS3...

function receiveSomething(o:Object):void {
// o[0].thing == sandwich, etc.
}
ExternalInterface.addCallback("sendObject",receiveSomething);



In AcroJS...

var myObj = [{label:"one",thing:"sandwich"},{label:"two",thing:"cake"}];
rma.callAS("sendObject", myObj); // returns undefined

floG23
Registered: Apr 21 2010
Posts: 14
just like this, i coded it the last hour...it works fine :) :) bad luck, that acrobat don´t save the "change" of the List-Objects for further times. now i`ll try to save it in an attached xml file, so that the List within the RMA can get his information from the xml file. it should be like an editor...

thank you
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
It would have helped if you'd explain what you're trying to do at the start. Storing stateful information between sessions is a whole different topic, and requires very specific techniques. You certainly can't use an RMA resource file as a read/write buffer, nor can a SWF annotation open file attachments made at the document level.
floG23
Registered: Apr 21 2010
Posts: 14
Using this idea ( http://pdfdevjunkie.host.adobe.com/RMA4_exportData.shtml )for "printing" data of my List in an xml file...Saving it (the xml file)...Another pdf-version should use this XML-File as his Information-Getter...
Should work...Or not?