1 2 Previous Next 56 Replies Latest reply: Jul 19, 2012 11:59 AM by DaLe Zki RSS

    FlashVars pass field text to swf

    Community Member
      I want to pass text to it from an acrobat field
      If I put this in the FlashVars it works

      myFlashVar=test

      But I want to place text from a field in the pdf

      var GuestNames = this.getField("Names");
      myFlashVar = (GuestNames)

      But I can't get it to work
      Can it be done?

      Can anyone help
      Thanks
        • 1. Re: FlashVars pass field text to swf
          Bernd Alheit CommunityMVP
          Use this:

          myFlashVar = GuestNames.value;
          • 2. Re: FlashVars pass field text to swf
            Community Member
            Thanks Heaps Bernd

            But its still not working I keep get Undefined

            I am using acrobat 9 FlashVars: box
            and Swf using actionscript 2

            This is the script in flash
            var myFlashVar:String;
            GuestsNames.text = myFlashVar;

            This is the script in the FlashVars:
            var GuestNamez = this.getField("TestText");
            myFlashVar = GuestNamez.value;

            Any help to fix this would be great.

            Daniel
            • 3. Re: FlashVars pass field text to swf
              Community Member
              Please can anyone help or tell me where I can find anything that explains this. There is no help on the adobe site or any SDK info to help that I can find.
              • 4. Re: FlashVars pass field text to swf
                Patrick Leckey Community Member
                > There is no help on the adobe site or any SDK info to help that I can find

                That's because this will be part of Acrobat SDK 9, which has not been released yet. Until it is released, you're entirely on your own.
                • 5. Re: FlashVars pass field text to swf
                  Community Member
                  Hi There Guys have looked through the Acrobat 9 sdk and have not been able to find much.

                  Can you help

                  I want to pass text to it from an acrobat field
                  If I put this in the FlashVars it works

                  myFlashVar=test

                  But I want to place text from a field in the pdf

                  I am using acrobat 9 FlashVars: box
                  and Swf using actionscript 2

                  This is the script in flash
                  var myFlashVar:String;
                  GuestsNames.text = myFlashVar;

                  This is the script in the movie properties Flash tab FlashVars:
                  var GuestNamez = this.getField("TestText");
                  myFlashVar = GuestNamez.value;

                  I can see the formatting I need to use and work as above but to do what I want I would then need to pass the string to the flashvars box in the movie options from ... and how?

                  Any help to fix this would be great.

                  Daniel
                  • 6. Re: FlashVars pass field text to swf
                    George_Johnson CommunityMVP
                    This isn't a direct answer, but you might want to check out the following to see if you can extract any ideas:
                    http://www.math.uakron.edu/~dpstory/acroflex.html

                    George
                    • 7. Re: FlashVars pass field text to swf
                      Community Member
                      Thanks George

                      What I am trying to do is get a query string from a web page that contains a pdf into the swf embedded in it. The query string holds name of people to use as a personalised invite done by sending an email with a link and query string to them.

                      The Idea is that i can send a personalised video invite to someone and using the web that they can view and save if they wish.

                      I can get the info from the query string into acrobat field but am having trouble passing it directly or indirectly to the swf embedded in the pdf.

                      Can you help.
                      • 8. Re: FlashVars pass field text to swf
                        George_Johnson CommunityMVP
                        No, but they did just release the Acrobat 9 SDK, and you may want to ask in a Flash/Flex forum if you have not already done so. I have not seen much discussion on this topic.

                        George
                        • 9. Re: FlashVars pass field text to swf
                          Community Member
                          Thanks again George

                          I have checked the sdk 9 very little info on flashvars. I can get the query string from web page containing a swf but not when it is embedded in a pdf it wont seem to do the leap. That is why I am trying to pass it from the pdf to flash, which is what the flashvars box in acrobat swf movie option looks like it is meant to do but I can't find any info on how to use it.

                          Please someone can you help.
                          • 10. Re: FlashVars pass field text to swf
                            Patrick Leckey Community Member
                            Now that Acrobat SDK 9 is officially released, you could log a Developer Support case with Adobe and get your answer from them.
                            • 11. Re: FlashVars pass field text to swf
                              DaLe Zki

                              Having a very similar challenge this morning.

                               

                              has anyone stumbled upon a solution?

                               

                               

                              i.e. How to have a SWF (embedded in a PDF) load a form's textfield: "value" ?

                               

                              Objectve: given

                              ~ SWF is embedded in PDF

                              ~ form fiel;d in PDF = "name1"

                               

                              Coding task;

                              how to code the SWF so that it can use the PDF texfield while

                              embedded in the PDF.

                               

                              Also, is this a push from PDF OR a pull from the SWF?

                               

                              ideas;

                              loadVars

                              myFlashVars

                              event.value string

                               

                              Many Thanks

                              Dale

                              • 12. Re: FlashVars pass field text to swf
                                Thom Parker CommunityMVP

                                You have a couple of options for passing data into the SWF, FlashVars are not one of them.  The Flash Vars are static.  They are passed into the SWF at the time it is started. 

                                 

                                But the other options are better. 

                                 

                                1.  In the SWF actionscript: Use the "ExternalInterface" object to call a function in the PDF.

                                2.  Add a callback to the SWF, again using the ExternalInterface object.  Then JavaScript code in the PDF can call this fucntion in the SWF

                                 

                                both are great options.  YOu can find more details here:

                                http://pdfdevjunkie.host.adobe.com/RMA3_RMA2RMA.shtml

                                 

                                And of course you should also read the AnnotRichMedia entry in the JavaScript Reference.

                                 

                                Thom Parker
                                The source for PDF Scripting Info
                                pdfscripting.com

                                 

                                The Acrobat JavaScript Reference, Use it Early and Often

                                 

                                Then most important JavaScript Development tool in Acrobat
                                The Console Window (Video tutorial)
                                The Console Window(article)

                                • 13. Re: FlashVars pass field text to swf
                                  DaLe Zki Community Member

                                  I appreciate you explaining the Flash Vars usage and how they function.

                                  I had assumed they were dynamic.

                                   

                                  I will use you suggestions and the pdfscripting.com site

                                  as my guide.......

                                   

                                  Thanks Thom

                                   

                                  As a reference, I am using my legecy

                                  CS3 Flash w/ Arcobat 8 Pro, scripting w/ AS2 & AS3

                                   

                                  Can I assume this will be vaild with you solutions?

                                   

                                  Many thanks.

                                  Dale

                                  • 14. Re: FlashVars pass field text to swf
                                    DaLe Zki Community Member

                                    Hi Thom

                                     

                                    Admittedly a novice on the AS3 & Java script side of things,

                                    I use your references and gave the coding an attempt...

                                     

                                    When you have a moment, I could use your review and

                                    some further direction.....

                                     

                                    Thanks in advance for your responses and help.

                                     

                                    Dale

                                     

                                    ~ ~ ~

                                    Givens on the SWF side;

                                     

                                    ~movie is published as: pdf_test.swf

                                    ~dymanic text instance: pdf_input

                                     

                                    ??confirm tis SWF script belongs in an 'action' layer (i.e. frame 1...) ??

                                     

                                     

                                    code (actionscript3)

                                    // to set up my function within my SWF

                                     

                                    function nametextinput("names1") {

                                    }

                                     

                                    //  to make my function available to the PDF java script

                                     

                                    var connection = ExternalInterface.addCallback("mypdfId", null, nametextinput);

                                     

                                    ~ ~ ~

                                    Givens on PDF side;

                                     

                                    ~file is saved as: text1.pdf

                                    ~form input textfield:  name1

                                     

                                    code (java script)

                                    // to send PDF's form text field to the embedded SWF

                                    // RMA is on page two, first RMA... and only RMA

                                     

                                    function sendtoswf()

                                    {     rma = this.getAnnotsRichMedia(1)(0)

                                    ExternalInterface.call("myPdfId", null, nametextinput)

                                    };

                                    • 15. Re: FlashVars pass field text to swf
                                      Thom Parker CommunityMVP

                                      You're almost there. But there are a few issues. 

                                       

                                      1.  Arguments to a function definition cannot be quoted strings.  They are basically variable names.  So if you want to pass in a single text string, i.e. the value of a field on the PDF then you could define the function like this:

                                       

                                      function nametextinput(cName) {

                                      }

                                       

                                      2.  The "addCallback" fucntion has two input parameters The name that will be used to call the function, and the actual fucntion that will be called.  And it does not have a return value.

                                      This is the correct code:

                                       

                                      ExternalInterface.addCallback("mypdfId",  nametextinput);

                                       

                                      3.  On the PDF side the "getAnnotsRichMedia" function returns an array of RMA objects

                                         So here's what the code should look like for calling the "mypdfId" function, assuming that there is only one RMA on the page

                                       

                                      var rma = this.getAnnotsRichMedia(1)[0];

                                      rma.callAS("mypdfId", this.getField("TextField").value);

                                       

                                      Thats how its done.

                                       

                                      Thom Parker
                                      The source for PDF Scripting Info
                                      pdfscripting.com

                                       

                                      The Acrobat JavaScript Reference, Use it Early and Often

                                       

                                      Then most important JavaScript Development tool in Acrobat
                                      The Console Window (Video tutorial)
                                      The Console Window(article)

                                      • 16. Re: FlashVars pass field text to swf
                                        DaLe Zki Community Member

                                        Thank you Thom

                                         

                                        I appreciate the details.....

                                        This provides a thorough understanding as to

                                        this objective.....

                                         

                                        Very helpful.... again.. Thanks!

                                         

                                        Dale

                                        • 17. Re: FlashVars pass field text to swf
                                          DaLe Zki Community Member

                                          Hi Thom

                                           

                                          Well I gave it the ole College try......

                                          and could not seem to get it to execute.

                                           

                                          Should you have a moment, I could use some more

                                          Schooling in where I have failed.

                                           

                                          Thanks in advance for your patience and help.

                                          Dale

                                          ~~~~

                                           

                                          In the SWF, I tried putting the code (below) first in

                                          the ""publish settings" using AS3, then

                                          tried an "action frame" in a new layer.. both attempts failed

                                           

                                          SWF code

                                          function nametextinput(cName) {

                                          }

                                          ExternalInterface.addCallback("mypdftext", nametextinput);

                                           

                                          ~~~

                                          In the PDF, I tried putting the code in first the 'text field properties', 'actions' tab

                                          using 'Trigger' as Mouse Enter and 'Action' as "run a JavaScript.... then

                                          used the "Validate" tab and tried the 'run a custom validation script'..... 

                                           

                                          PDF code

                                          var rma = this.getAnnotsRichMedia(1)[0];

                                          rma.callAS("mypdftext", this.getField("TextField").value);

                                           

                                           

                                          other references;

                                          CS3 Flash Pro

                                          Acrobat 8 Pro

                                           

                                          All combo's, herein, did not execute.

                                          Thanks again!

                                          • 18. Re: FlashVars pass field text to swf
                                            Dave Merchant CommunityMVP

                                            As a reference, I am using my legecy

                                            CS3 Flash w/ Arcobat 8 Pro, scripting w/ AS2 & AS3

                                             

                                            Ahem... NO.

                                             

                                            Everything Thom and others have said refers to Rich Media Annotations, and those are only available in Acrobat 9 and later.

                                            • 19. Re: FlashVars pass field text to swf
                                              DaLe Zki Community Member

                                              Thanks Dave for the note re Arcobat.

                                               

                                              I'll explore upgrading my CS Suite...

                                              Dale

                                              • 20. Re: FlashVars pass field text to swf
                                                Thom Parker CommunityMVP

                                                Good catch Dave, thanks

                                                 

                                                Dale,  When you are trying to learn something new its' a good idea to start off simple, and to have a way to check your work.  For example, all of the previous code you've posted would have thrown exceptions.   These exceptions are an important debugging tool.  I 'd suggest becoming familiar with the Acrobat JavaScript Console.  And to make things simple, place all of your code in a MouseUp event on a button. Remove all code from the events on the text field.  As a matter of fact, start with a blank PDF that only contains the elements you need for this solution, a button, a text field, and the RMA.

                                                 

                                                That takes care of the Acrobat JavaScript side.  Now you need a way to verify the Flash side.  Build your test Flash project with a single button and a text field.  Make sure you know how to update text in the text field.   Then write the function that will be called from the external interface to place text in this field. 

                                                 

                                                On another note, the "addCallback" function should be called in the "ApplicationComplete" event of the SWF so it is setup right after the SWF is ready to play

                                                 

                                                Thom Parker
                                                The source for PDF Scripting Info
                                                pdfscripting.com

                                                 

                                                The Acrobat JavaScript Reference, Use it Early and Often

                                                 

                                                Then most important JavaScript Development tool in Acrobat
                                                The Console Window (Video tutorial)
                                                The Console Window(article)

                                                • 21. Re: FlashVars pass field text to swf
                                                  DaLe Zki Community Member

                                                  Thom ~ Thanks

                                                   

                                                  Very sound advice...... not surprising,

                                                  my first scripting in Java / Acrobat requires

                                                  a bit of due diligence.... 'study the basic fundamentals'.

                                                   

                                                  I would welcome staying in touch as I

                                                  muscle through this personal project.

                                                   

                                                  Kind regards,

                                                  Dale

                                                  • 22. Re: FlashVars pass field text to swf
                                                    DaLe Zki Community Member

                                                    Hi Thom,

                                                     

                                                    I trust your New Year is off to a creative start.

                                                     

                                                    RE: Text Field pass into SWF

                                                    ~

                                                    Below is an update and a request for "fine tuning" these codes;

                                                     

                                                    ~ I have upgraded to FLASH CS5 and ACROBAT X Pro

                                                    ( I have not studied FLEX)

                                                     

                                                    I spent some time studying the Acrobat JavaScript Reference, JavaScript Debugger and reversed

                                                    engineered the PDF in the link you provided;

                                                     

                                                    http://pdfdevjunkie.host.adobe.com/RMA1_acrossTheBridge.shtmlhttp://

                                                     

                                                    Still, I must be missing something; a variable or syntax, format..., software version...

                                                     

                                                    When you have a chance, I again, could use your coaching on what

                                                    I have missed or haven't yet understood.

                                                     

                                                    Thanks in advance for your continued patience...

                                                     

                                                    here's my facts:

                                                     

                                                    SWF side using FLASH CS5

                                                     

                                                    ActionScript 3

                                                    1) inserted a dynamic text on the stage, with a single frame, with NO instance name, "classic", and embedded my fonts

                                                    2) create an action layer with the following code (using AS3);

                                                     

                                                    function nametextinput(fname) {

                                                    }

                                                    ExternalInterface.addCallback("pdfname", nametextinput);

                                                     

                                                    3) saved, then published the file   pdfname.swf

                                                     

                                                    ~ ~

                                                    PDF side using Acrobat X Pro

                                                     

                                                    Per your suggestion;

                                                    One page, a text field, a Button and the   RMA  pdfname.swf

                                                     

                                                    1) inserted a Form, Text-Field and named it   'fname'  (without the ' ' ) ... no coding anywhere with the Text Field Properties

                                                    2) Inserted a Button ~ within the Properties, under the Action Tab, a Mouse Up trigger was added with a Run JavaScript action

                                                    3) within this JavaScript Editor the following code was placed;

                                                     

                                                    var rma = this.getAnnotsRichMedia(0)[0];

                                                    rma.callAS("pdfname", this.getField("fname").value);

                                                     

                                                    4) saved PDF as   basic_v1.pdf

                                                     

                                                    Using the JavaScript Debugger, I continually receive errors.

                                                    I have attempted many adjustments, i.e. Brackets / Syntax / naking conventions to no avail.

                                                     

                                                    When I reverse engineered the PDF example ( ref above) I noted that codes

                                                    differ slightly from your suggestions (CAPs, more Brackets, and an app.alert is check if the RMA is Active !?). 

                                                     

                                                    I attempted adjusting for that, but again, unsuccessfully.

                                                     

                                                    So, again, I like'd to understand what I am missing as

                                                    much as I'd like to complete this objective.

                                                     

                                                    When you have a chance, I would welcome you help.

                                                     

                                                    Many thanks,

                                                     

                                                    Dale

                                                    Fremont, CA

                                                    • 23. Re: FlashVars pass field text to swf
                                                      Dave Merchant CommunityMVP

                                                      You're getting confused with what's a function name and what's the name of the document and there are some quotes missing - but you can basically forget all of that anyway. There's no need for anything to be added to the document JS. Instead, simply use the eval() method. Assuming your form field is called 'fname', in your SWF just run this one line of code:

                                                       

                                                      fieldValue = ExternalInterface.call("eval","getField('fname').value");

                                                       

                                                      Note the use of double and single quotes. You can use eval() to send anything which returns a single value, from the name of a variable to an entire function.

                                                      • 24. Re: FlashVars pass field text to swf
                                                        DaLe Zki Community Member

                                                        Thank you Dave,

                                                         

                                                        I really apprecaite your comments.

                                                        This is a great help with the learning curve.

                                                         

                                                        I'll adjust the SWF code and test it in the PDF..

                                                         

                                                        Many thanks !

                                                        • 25. Re: FlashVars pass field text to swf
                                                          DaLe Zki Community Member

                                                          Hi Dave,

                                                           

                                                          I used your suggestion by doing the following;

                                                           

                                                          While in FLASH, used the single line of code you listed, paying special attention to the use of quotes.

                                                          Yes, the name of the PDF text field is  (fname).

                                                           

                                                          Within the PDF, I did not remove / adjust the JavaScript on the MouseUp Button.

                                                          ~~~

                                                          Unfortunately, my attempt w/ this method did not

                                                          transfer the TextField data input into the SWF (RMA).

                                                           

                                                          Clicking the SWF and or the Button (w/ JS) and combinations did not produce the result.

                                                           

                                                          Troubleshooting included:

                                                          Editing the SWF once placed in the PDF (SWF properties): played with 'Launch' /Activation Settings, considered the use of the 'properties' SWF and Resource TABs, to no avail.......

                                                           

                                                          When you have a chance, let me know what /where I may be failing at this attempt......it's a tougher learning curve than I had anticipated.

                                                           

                                                          Thanks

                                                          Dale

                                                          • 26. Re: FlashVars pass field text to swf
                                                            Joel_Geraci Community Member

                                                            Dale:

                                                             

                                                            If you want the trigger for passing the PDF form field value to the text object in the SWF, your ActionScript code would look like this...

                                                             

                                                            myText.text = ExternalInterface.call("eval","getField('fname').value");

                                                             

                                                            If you want to trigger to be in the PDF file, the SWF will need to be running and then you need to call an exposed function and pass in your variable.

                                                             

                                                            Start by adding a function in ActionScript that sets the valie of your text object, then add a function for creationComplete that adds a callback for that function. init() is my creationComplete function and I expose the same internal name to the external interface just to keep things clear.

                                                             

                                                                        private function init():void{

                                                                                  ExternalInterface.addCallback("fillText", fillText)

                                                                        }

                                                                       

                                                                        private function fillText(valueFromAcroField:String):void {

                                                                            myText.text = valueFromAcroField;

                                                                        }

                                                             

                                                            Then use callAS to call the SFW function from Acrobat. Assuming your annotation is "RMA" that'd be...

                                                             

                                                            RMA.callAS("fillText", getField('fname').value)

                                                             

                                                            It's a lot of plumbing but it works.

                                                             

                                                            J-

                                                            • 27. Re: FlashVars pass field text to swf
                                                              DaLe Zki Community Member

                                                              Joel,

                                                              Thanks for your response;

                                                               

                                                              within the SWF... using AS3,

                                                              dynamic text field with no

                                                              instance name...

                                                              I have received this error : "1013: the private attribute maybe used only on class property definitions"

                                                               

                                                              I have yet to dive into using / understanding the effective use of "Class".

                                                              Your guidance would be very appreciated....

                                                               

                                                              Just for my notes, my SWF file was developed in FLASH CS5 and

                                                              was 'published; with the file name  pdfname.swf  .

                                                               

                                                              What I want to understand is your reference "Assuming your annotation is RMA".

                                                               

                                                              Using Acrobat X Pro,

                                                              I added my said SWF (pdfname.swf) file via Content / Multimedia / SWF

                                                               

                                                              Is this SWF and your RMA reference one in the same?

                                                              I just want to make clear I am learning the right terminology.

                                                               

                                                              Should the RMA be something other than my current "steps",

                                                              I would welcome any clarification.

                                                               

                                                              Thanks in advance for your time.

                                                               

                                                              D

                                                              • 28. Re: FlashVars pass field text to swf
                                                                Joel_Geraci Community Member

                                                                You'll need a way to identify the particular tect field you want to change the "text" parameter of in the function that you call from Acrobat then you need to expose that function so that Acrobat can call it.

                                                                 

                                                                The examples at the URL below will show you how to call an ActionScript function from Acrobat.

                                                                 

                                                                http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp. htm?&accessible=true

                                                                 

                                                                The documentation at the URL below explains ExternalInterface. The docs refer to a browser but in this case the host is Acrobat or Reader.

                                                                 

                                                                http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/External Interface.html

                                                                 

                                                                J-

                                                                • 29. Re: FlashVars pass field text to swf
                                                                  DaLe Zki Community Member

                                                                  Hi Joel,

                                                                   

                                                                  First I like to say I enjoyed your video on "AcrobatUsers.com" re: inserting QR codes.... this was very helpful

                                                                   

                                                                  http://acrobatusers.com/tutorials/adding-rich-media-your-pdf-files-november-2011

                                                                   

                                                                  ~~

                                                                  Per your Mar 2, post, I was attempting the AS3 code within my SWF ( no coding within the PDF)

                                                                  I tried to resolve the following errors without success. (i.e. brace inputs, changing quotes...)

                                                                   

                                                                  I would appreciate your guidance.....

                                                                   

                                                                  Thanks for your help.

                                                                  Dale

                                                                   

                                                                  Errors

                                                                  1084 Syntax error: expecting identifier before "getField('fname').value".

                                                                  1084 Syntax error: expecting rightparen before rightbrace.

                                                                  • 30. Re: FlashVars pass field text to swf
                                                                    Joel_Geraci Community Member

                                                                    Without seeing the surrounding code, I can't really help much. Remember that you Acrobat JavaScript need to be inside and ExternalInterface call like this...

                                                                     

                                                                    myText.text = ExternalInterface.call("eval","this.getField('fname').value");

                                                                     

                                                                    J-

                                                                    • 31. Re: FlashVars pass field text to swf
                                                                      DaLe Zki Community Member

                                                                      Hi Joel,

                                                                       

                                                                      I really appreciate your prompt response.

                                                                      ~~

                                                                      I have manage to get myself quite confused...

                                                                       

                                                                      Using your two options suggested on Post #26 above,

                                                                      I read the first option as an AS3 to be within a/my SWF file.

                                                                      And assumed there was no JavaScripting on the PDF side

                                                                      (i.e pulling the PDF test field ('fname') into the SWF via AS3)

                                                                       

                                                                      When you have a chance, I could use a thorough walk through...

                                                                       

                                                                      Many thanks.....

                                                                       

                                                                      Dale

                                                                      • 32. Re: FlashVars pass field text to swf
                                                                        Joel_Geraci Community Member

                                                                        Dale:

                                                                         

                                                                        The Flash runtime inside Acrobat does not have direct access to anything in the PDF. In fact, it barely knows it running in Acrobat rather than a browser. All it know is that it's running in a host. So... for the SWF to get information from the PDF, you need to send the PDF some JavaScript that returns some value. You can then use that return value to do things in your SWF. How does that work.

                                                                         

                                                                        Acrobat JavaScript, unlike ActionScript, has an "eval" function that will cause a string to be evaluated and executed as though it were code, we can take advantage of this inside Flash. If you were in Acrobat and you wanted to know the value of a field named "foo" then JavaScript would be...

                                                                         

                                                                        myVal = this.getField("foo").value

                                                                         

                                                                        ... to get this information from inside a running SWF in Acrobat, you need to push the code into Acrobat through ExternalInterface and the return value will be your variable. We need to change the double quotes to single so we can nest them.

                                                                         

                                                                        var fieldValue:String = ExternalInterface.call("eval","getField('foo').value");

                                                                         

                                                                        Technically, there's no JavaScript in the PDF itself, this JavaSCript just runs in memory. If you're going to work withthis sort of thing you need a good understanding of both ActionScript AND Acrobat JavaScript.

                                                                         

                                                                        Is that more.... or less clear?

                                                                         

                                                                        J-

                                                                        • 33. Re: FlashVars pass field text to swf
                                                                          DaLe Zki Community Member

                                                                          Hi Joel,

                                                                           

                                                                          below is my AS3 attempt last evening;

                                                                           

                                                                          // as if used in a Browser

                                                                          varLoader: URLLoader = new URLLoader();

                                                                           

                                                                          // noting the "fname" is the textfield name in Acrobat

                                                                          loader.load(new URLRequest("fname"));

                                                                           

                                                                          loader.addEventListner(Event.COMPLETE, onComplete);

                                                                          function onComplete(event:Event):void

                                                                          {

                                                                          // 'myText' is the instance name of the dymanic textfield, with 'fname' the textfield with Acrobat

                                                                          myText.text = ExternalInterface.call("eval","this.getfFeld('fname').value");

                                                                          }

                                                                           

                                                                          Note: no JavaScripts were performed in Acrobat

                                                                          I look forward to your guidance.....

                                                                           

                                                                          Dale

                                                                          • 34. Re: FlashVars pass field text to swf
                                                                            Joel_Geraci Community Member

                                                                            You just need this part

                                                                             

                                                                            myText.text = ExternalInterface.call("eval","this.getfFeld('fname').value");

                                                                             

                                                                            You don't need to use the loader.

                                                                             

                                                                            J-

                                                                            • 35. Re: FlashVars pass field text to swf
                                                                              DaLe Zki Community Member

                                                                              Joel,

                                                                               

                                                                              Your explanation noted above was very clear,

                                                                              both in context and what I need to study.

                                                                               

                                                                              So, when I attempted to use only the code noted above ( with any other AS3, Braces {}...)

                                                                              I keep getting syntax errors 1084 noted in my post#29 above...

                                                                               

                                                                              Other notes.....

                                                                              currently I have my dynamic text with an instance name of myText... is this proper?

                                                                               

                                                                              Dale

                                                                              • 36. Re: FlashVars pass field text to swf
                                                                                DaLe Zki Community Member

                                                                                Joel

                                                                                 

                                                                                for clarity

                                                                                I meant to type "without any other AS3, Braces {}..."

                                                                                 

                                                                                I have fixed the Syntax error, while review the code, I noted  "this.  was added in a recent reply.

                                                                                That seemed to address this challenge.

                                                                                 

                                                                                I am currently addressing an output error: TypeError: Error 2007: Parameter must be non-null.

                                                                                at Flash.text::TextField/set text ()

                                                                                at pdfname_fla::MainTimeline/ frame 1

                                                                                 

                                                                                While researching this, I would welcome your insight.....

                                                                                as a reference, the SWF dynamic text field instance is named  myText ( unsure if this is the/an issue)

                                                                                 

                                                                                Thanks again for your time......

                                                                                 

                                                                                D

                                                                                • 37. Re: FlashVars pass field text to swf
                                                                                  Joel_Geraci Community Member

                                                                                  Looks like I had a typo... try this...

                                                                                   

                                                                                  this.myField.text = ExternalInterface.call("eval","this.getField('fname').value");

                                                                                  • 38. Re: FlashVars pass field text to swf
                                                                                    DaLe Zki Community Member

                                                                                    UPDATE March 19, 2012 ~DS:

                                                                                     

                                                                                    No Errors, but no Text Interface (between PDF & SWF)

                                                                                     

                                                                                    With the Codes noted below, there are no AS3 "Output / Compiler errors"

                                                                                    and on the Acrobat side, JavaScript debugger did not report any errors.

                                                                                     

                                                                                     

                                                                                    With the SWF (RMA) loaded in the PDF... the two text fields are still not interfacing (PDF to SWF).

                                                                                     

                                                                                     

                                                                                    Please take a look at the retyped** Codes and notes posted below and

                                                                                    let me know how you would adjust.

                                                                                     

                                                                                    SWF side:

                                                                                     

                                                                                    Dynamic text instance:  namehere

                                                                                    Button name: play_btn

                                                                                    file saved as:  swf_to_pdf.swf

                                                                                     

                                                                                    Code AS3

                                                                                    full retyped script as stated in SWF

                                                                                     

                                                                                    /* "swfPdf" is used to 'call the function' (use this in the Acrobat PDF JavaScript)

                                                                                        'fillText' is the actual function seen below that will be called

                                                                                         'fname' referenced in fillText function(below), is the Acrobat textField name

                                                                                    */

                                                                                     

                                                                                     

                                                                                    // Button set up

                                                                                     

                                                                                    function clickHandler(event:MouseEnter):void

                                                                                    {

                                                                                         trace("Click!");

                                                                                         ExternalInterface.addCallback("swfPdf", fillText);

                                                                                     

                                                                                              function fillText(fname):void

                                                                                              {

                                                                                                   this.namehere.text = this.ExternalInterface.call("eval", "this.getField('fname').value");

                                                                                              }

                                                                                    }

                                                                                     

                                                                                     

                                                                                              // assign Listener

                                                                                                  play_btn.addEventListener(MouseEvent.CLICK, clickHandler);

                                                                                     

                                                                                    ~ ~

                                                                                    PDF side

                                                                                     

                                                                                    PDF has one page and only one RMA (0)[0]

                                                                                     

                                                                                    Form Text field:  fname

                                                                                    Button (name):   play

                                                                                    file saved as:  pdf_rma_test.pdf

                                                                                     

                                                                                    OnMouse Up, the code within the Button reads as follows

                                                                                    (full, retyped JavaScript as stated in PDF);

                                                                                     

                                                                                    var rma = this.getAnnotsRichMedia(0)[0];

                                                                                    rma.callAS("sfwPdf", getField('fname').value);

                                                                                     

                                                                                     

                                                                                    Notes and observations:

                                                                                     

                                                                                    While no errors were thrown on either side, please consider the following;

                                                                                     

                                                                                    AS3 side

                                                                                    • ? within the "function fillText", is fname the correct reference
                                                                                    • ? this use of "this. "... does this reference need to be addressed on the Acrobat side
                                                                                    • Does the AS3 script require an 'import' reference script  i.e.  import flash.external.ExternalInterface;
                                                                                    • Does there need to be a script to to Play the SWF file immediately.. note, upon embedding in the PDF, the SWF is 'enabled' when the page is opened.. 
                                                                                    • Any special Publishing settings
                                                                                    • any other Commands required

                                                                                     

                                                                                    Acrobat side

                                                                                    • ? does the getField require a this. before it
                                                                                    • ? confirm single or double quotes around fname reference

                                                                                     

                                                                                    Other

                                                                                    • Trigger(s), i.e. the use of the Button in the PDF

                                                                                     

                                                                                    • Launch settings(advanced options of SWF in the PDF)

                                                                                              Can this effort the communication ??

                                                                                                   currently set as Enable When: the page containing the content is opened

                                                                                                                          Disable When: the page containing the content is closed

                                                                                     

                                                                                     

                                                                                    ** is there away to cut & paste code within a Forum / Discussion?

                                                                                     

                                                                                    Many thanks for your time and guidance.....

                                                                                     

                                                                                    D~

                                                                                     

                                                                                    Message was edited by: DaLe Zki on March 19, 2012....

                                                                                    • 39. Re: FlashVars pass field text to swf
                                                                                      DaLe Zki Community Member

                                                                                      Hi Thom,

                                                                                       

                                                                                      As I am unsure if you are prompted with new / updated Discussion Posts, I would

                                                                                      welcome your feedback on my most recent coding for this project.

                                                                                       

                                                                                      See Post #38

                                                                                       

                                                                                      In sumamry, there are no errors on the SWF AS3 side nor the Acrobat Javascript side, and yet,

                                                                                      the to Text Fields are not interfacing.

                                                                                       

                                                                                      Thanks in advance for any time you can spare.....


                                                                                      Dale

                                                                                      1 2 Previous Next