actionscript 3 - AS3: zoom and pan movieclip in adobe air android -



actionscript 3 - AS3: zoom and pan movieclip in adobe air android -

i using gestouch library on github.https://github.com/fljot/gestouch

zoomall movieclip, able zoom in , out @ specific point. here code,

import org.gestouch.events.gestureevent; import org.gestouch.gestures.zoomgesture; var zoom: zoomgesture*; zoom = new zoomgesture(zoomall); zoom.addeventlistener(org.gestouch.events.gestureevent.gesture_began, ongesture); zoom.addeventlistener(org.gestouch.events.gestureevent.gesture_changed, ongesture); function ongesture(event: org.gestouch.events.gestureevent): void { const gesture: zoomgesture = event.target zoomgesture; var matrix: matrix = zoomall.transform.matrix; var transformpoint: point = matrix.transformpoint(zoomall.globaltolocal(zoom.location)); matrix.translate(-transformpoint.x, -transformpoint.y); matrix.scale(gesture.scalex, gesture.scaley); matrix.translate(transformpoint.x, transformpoint.y); zoomall.transform.matrix = matrix; }

here want restrict zoom in , out specific scale. , want pan movieclip(zoomall) , should not pan outside device screen.

you realize calling matrix.scale(b, b) * b = c, a current scale , c resulting scale? if don't want c bigger maximum maxc, should limit b:

b = math.min(b, maxc / a)

same minimum minc:

b = math.max(minc / a, b)

so have:

// assuming maintain scale ratio var mins:number = min_scale / zoomall.scalex; var maxs:number = max_scale / zoomall.scalex; var s:number = math.max(mins, math.min(gesture.scalex, maxs)); matrix.scale(s, s);

actionscript-3 flash air

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -