5 Replies Latest reply on Jul 31, 2006 1:47 AM by dontworrybehappy

    What script for Zoom in/ out of image?

    sdiuhwer
      1. I plan to import quite bigger bitmap image and save as a Graphic Symbol

      2. Make some Botton Symbols for +(Zoom in, -(Zoom out) and Reset.

      3. If I click +(Zoom in) button, image (reduced sized image in smaller window) got magnified.

      ----> What scripts do I need for this design? I'm working on Flash8.
      Thanks much in advance!!



      *** I got this idea from the site of
      http://www.metmuseum.org/explore/cezannes_apples/look.html
      And click "Let's Look Closely"...
        • 1. What script for Zoom in/ out of image?
          Level 1
          First of all, dont put your image as a graphic symbol ... use movieClip instead.

          Lets say you transform it into a movieClip and give it the instance "image" and that your zoom button is called zoomBtn and the un-zoom button is called unZoomBtn:

          //--> start the loop for zooming in on "press" event
          zoomBtn.onPress = function(){
          this.onEnterFrame = zoomIn;
          }
          //--> start the loop for zooming out on "press" event
          unZoomBtn.onPress = function(){
          this.onEnterFrame = zoomOut;
          }

          //--> stop the loop for zooming in or out on "release" event of both buttons
          zoomBtn.onRelease = unZoomBtn.onRelease = function(){
          delete this.onEnterFrame;
          }

          //--> line of code executed in loop for the zoom in
          function zoomIn(){
          image._xscale = image._yscale += 5;
          }
          //--> line of code executed in loop for zoom out
          function zoomOut(){
          image._xscale = image._yscale -= 5;
          }
          • 2. Re: What script for Zoom in/ out of image?
            sdiuhwer Level 1
            bucho, thank you very much for your valuable information. I am not quite good at actionscripting even though I got excited about this design/ idea. I would need some time to test but if possible, I would get back to you how it works. Thanks again.
            • 3. Re: What script for Zoom in/ out of image?
              dontworrybehappy
              Thanx butcho,
              similar prblm i was also facing... i tried the actionscript u supplied. No doubt it should have worked but unfortunately for me i got the following errors in the output window. pl help. I am base level learner and need help. I hope to get the support.
              Thanks in anticipation.



              **Error** Scene=Scene 1, layer=pan&zoom, frame=1:Line 1: Statement must appear within on handler
              this.press = function(){

              **Error** Scene=Scene 1, layer=pan&zoom, frame=1:Line 4: Statement must appear within on handler
              this.release = function(){

              **Error** Scene=Scene 1, layer=pan&zoom, frame=1:Line 7: Statement must appear within on handler
              function zoomIn(){

              Total ActionScript Errors: 3 Reported Errors: 3

              • 4. Re: What script for Zoom in/ out of image?
                Level 1
                Hi dontworrybehappy ,

                the lines of code i provide have to be in a frame. It seems like you paste the code on an object like a movieclip. Try it in a frame but of course the buttons will need to be accessible at that frame wich mean it has to exist. It will not work if the buttons only exist 4 frames after the code.
                • 5. Re: What script for Zoom in/ out of image?
                  dontworrybehappy Level 1
                  Thanx for the Support, Butcho. Although the errors disappeared once I put the code in frame, the prblm could not resolved since there was no zoom in/out effect in the "image". As advised by you, i have put the code & zoombtn, unzoombtn in the same frame alongwith the "image". Kindly help.