5 Replies Latest reply on May 3, 2017 10:25 AM by ClayUUID

    double tap to ZOOM

    angelom77716812

      Im new to coding and been practicing for a shol project.

       

      Im trying to put a fuction on an element so it doubles the size on a double click, and then zoom out again if double clicked again.

      Ive been trying this with gesture events, yet im not having much luck, ive been trying with press and hold as well.

      Any help on how i could do this?

        • 1. Re: double tap to ZOOM
          ClayUUID Adobe Community Professional

          You're asking two questions-- how do you detect a double tap, or how do you zoom. Which is it?

          1 person found this helpful
          • 2. Re: double tap to ZOOM
            angelom77716812 Level 1

            Oh, both questions then, i think

            • 3. Re: double tap to ZOOM
              ClayUUID Adobe Community Professional

              And is this an AS3 or Canvas project?

              1 person found this helpful
              • 4. Re: double tap to ZOOM
                angelom77716812 Level 1

                It is AS3

                • 5. Re: double tap to ZOOM
                  ClayUUID Adobe Community Professional

                  Here is an example. If you have a movieclip on the stage named "ball", this will do what you claim to want:

                   

                  import flash.events.Event;

                  import fl.transitions.Tween;

                  import fl.transitions.easing.*;

                   

                  ball.doubleClickEnabled = true;

                  ball.addEventListener(MouseEvent.DOUBLE_CLICK, doZoom);

                   

                  function doZoom(e:Event):void {

                      var _this = e.target;

                      if (!_this.init) {

                          _this.init = true;

                          _this.zoomed = false;

                          _this.origXS = _this.scaleX;

                          _this.origYS = _this.scaleY;

                      }

                      var zoomScale:Number = 2;

                      var zoomFrames:Number = 15;

                      if (!_this.zoomed) {

                          // zoom

                          _this.zoomed = true;

                          new Tween(_this, "scaleX", Strong.easeOut, _this.scaleX, zoomScale, zoomFrames);

                          new Tween(_this, "scaleY", Strong.easeOut, _this.scaleY, zoomScale, zoomFrames);

                      }

                      else {

                          // unzoom

                          _this.zoomed = false;

                          new Tween(_this, "scaleX", Strong.easeOut, zoomScale, _this.origXS, zoomFrames);

                          new Tween(_this, "scaleY", Strong.easeOut, zoomScale, _this.origYS, zoomFrames);

                      }

                  }

                  1 person found this helpful