11 Replies Latest reply on May 5, 2011 11:03 PM by ForrestGimp

    Action on zoom event

    ForrestGimp

      Hi

      I have developed a flash-RMA which shows some text. The RMA is embedded  in a pdf. I discovered that sometimes, when zooming in acrobat/reader  the text is not displayed correctly (i.e. linebreaks shift, somtimes the  last line of text drops out of the viewingrange).

      I have a redrawing-function in my flash-as which forces a correct redraw  of the text and fixes this problem. However, so far I have to trigger  this function per hand (i.e. using a button).

      What I need now is an eventlistener, which calls the function  automaticly whenever a zoom-event occurs. I know how to call  AS-functions, but I have no clue about event-listeners in Acrobat.

        • 1. Re: Action on zoom event
          George_Johnson MVP & Adobe Community Professional

          It would have to be implemented in a custom plug-in. There is nothing lke what you want exposed to JavaScript. apart from periodically checking the page number and zoom setting using a timer.

          1 person found this helpful
          • 2. Re: Action on zoom event
            ForrestGimp Level 1

            Are you sure?

             

            A plugin is not an option, as the thing is intended to run  out-of-the-box on every reader above version 9. I was hoping there was at least some kind of "page-refresh" or "page-redraw"-event I could catch. So there is nothing to check when a change occurrs in the zoomfactor (except for the obvious timer - which I consider a rather dirty workaround)?

             

            Maybe I should actually report this text-issue as an acrobat-bug and use a timer in the meantime.

             

            Thanx for the advice anyhow.

            • 3. Re: Action on zoom event
              George_Johnson MVP & Adobe Community Professional

              Here's a list of events that you can attach code to:  http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.565.html

               

              I agree the timer idea is less than ideal, but it's all you've got to work with.

              • 4. Re: Action on zoom event
                ForrestGimp Level 1

                Thanks again.

                 

                This page is exactly what I found after digging into the documentation, and I checked all the events, but found none to suit my needs. However I hoped for some secret acrobat knowledge ^^.

                 

                Well, I got the timer working and it does the job for now. In case someone is interested, what I did was (in the document-script):

                var lastZoom = this.zoom;
                function checkZoom()
                {
                     if(this.zoom!=lastZoom)
                     {
                          this.getAnnotsRichMedia(0)[0].callAS('redrawtext');         
                          lastZoom = this.zoom;
                     }
                }
                var zoomChecker = app.setInterval('checkZoom()',500);"
                • 5. Re: Action on zoom event
                  Dave Merchant MVP & Adobe Community Professional

                  As you're talking about reflowing SWF content rather than PDF pages, you can simply add a listener in your ActionScript for the stage resize event.

                  • 6. Re: Action on zoom event
                    ForrestGimp Level 1

                    That would indeed be a more elegant solution. I have tested adding (in my flash-AS-class)

                    stage.addEventListener(Event.RESIZE, test);

                    private function test(e:Event)
                    {
                         *update text*
                    }

                    But it doesn't work in Acrobat (in the Flash-player it does!) It seems the event isn't triggered by zoom-actions in acrobat.

                    • 7. Re: Action on zoom event
                      Dave Merchant MVP & Adobe Community Professional

                      Yes it works, but you'll need to make sure your stage scaling mode is set correctly

                       

                      stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;

                       

                      You then deal with the resizing of your content within the event handler. Using the other modes (SHOW_ALL, NO_BORDER, EXACT_FIT) the stage is never resized as far as the timeline is concerned, rather the Player engine adapts it to suit.

                      • 8. Re: Action on zoom event
                        ForrestGimp Level 1

                        I see. Thanx for the tip!

                         

                        The event-handler does work now, but I run into a new problem: my flash-annotation is now excluded from the zoom. By "deal with the resizing of your content within the event handler" do you mean I should counteract this by running through all elements on my stage and adjusting the size according to the new stage-size?

                         

                        P.s.: I just checked and in ReaderX the RMA is not shown at all now! I didn't notice yet, as I still do most of the work with 9ProExtended (I have access to AcrobatX, but only very limited - I have to use a colleagues' workstation to do so).

                         

                        Message was edited by: ForrestGimp

                        • 9. Re: Action on zoom event
                          ForrestGimp Level 1

                          OK, so for my case I have returned to the simple-and-dirty solution.

                           

                          If you want to view the results (and some more of the cool stuff we made) you can check them out on http://www.docunamic.de/referenzen/
                          The page is only available in german for now, but downloading should be possible anyhow . There's quite a few examples for video-, flash- and 3D-PDFs. Enjoy!

                           

                           

                          P.S. Feel free to post any comments!

                          • 10. Re: Action on zoom event
                            Dave Merchant MVP & Adobe Community Professional

                            Yes, if the SWF is using NO_SCALE it's up to you to reposition or scale the elements on the stage, by reacting to the stage resize events. You could simply scale the entire lot, or reposition them individually.

                             

                            Rich Media annotations will work the same in Acrobat and Reader 9 and X, so if yours is not displaying properly in Reader X there is a problem with the document. Which file is it on your website?

                            1 person found this helpful
                            • 11. Re: Action on zoom event
                              ForrestGimp Level 1

                              You're right, there was a problem with the file.... I can't recall what it was, or how I fixed it, but it was just a minor issue. Anyway, it is the file you can download under http://www.docunamic.de/files/9912/9847/9610/docunamic_video_pdf_seeberger.pdf that originally gave me trouble. When switching languages it worked just fine, but once I started zooming the PDF parts of the text sometimes disappeared like described above.The version you can download has the fix applied, but if necessary I can provide a simplified version to illustrate the problem.

                               

                              It seems like the Zoomfactor of the PDF is not consistently applied to the scaling of flash-text. That's the basic issue.