Skip to main content
angelom77716812
Participant
May 3, 2017
Answered

double tap to ZOOM

  • May 3, 2017
  • 1 reply
  • 654 views

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?

This topic has been closed for replies.
Correct answer ClayUUID

It is AS3


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 reply

Legend
May 3, 2017

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

angelom77716812
Participant
May 3, 2017

Oh, both questions then, i think

Legend
May 3, 2017

And is this an AS3 or Canvas project?