Learn how to use the new gesture support in Flash Player 10.1 and Adobe AIR 2.0.
Length: 23:52
간만에 놀러간 gotoandlearn에서 제스처 인터렉션에 대한 영상을 보았다.
이렇게 심플하게 효과를 낼 수 있다니 놀랍다.
난 전체적인 알고리즘을 작성해야 할 줄 알았는데 이벤트 리스너 등록만으로 쉽게 처리되는 것을 보고는… @_@
위 예제 다운로드가 안되어서 사용된 코드를 직접 이곳에 작성한다.
package { import flash.display.StageDisplayState; import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.display.Sprite; import flash.events.MouseEvent; import flash.events.TransformGestureEvent; public class GestureSampleCode extends Sprite { private var con:Sprite; public function GestureSampleCode() { stage.displayStage = StageDisplayState.FULL_SCREEN_INTERACTIVE; stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, this.onZoom); stage.addEventListener(TransformGestureEvent.GESTURE_ROTATE, this.onRotate); this.init(); } private function init ():void { this.con = new Sprite(); this.con.x = stage.stageWidth * 0.5; this.con.y = stage.stageHeight * 0.5; this.addChild(this.con); for (var i:int = 0; i < 10; i++) { var b:Sprite = Sprite(new box()); b.x = Math.random() * stage.stageWidth - (stage.stageWidth * 0.5); b.y = Math.random() * stage.stageHeight - (stage.stageHeight * 0.5); b.rotation = Math.random() * 360; b.addEventListener(MouseEvent.MOUSE_DOWN, this.onDown); b.addEventListener(MouseEvent.MOUSE_UP, this.onUp); b.addEventListener(TransformGestureEvent.GESTURE_ZOOM, this.onZoom); b.addEventListener(TransformGestureEvent.GESTURE_ROTATE, this.onRotate); this.con.addChild(b); } } private function onDown(e:MouseEvent):void { var b:Sprite = Sprite(e.currentTarget); this.con.addChild(b); b.startDrag(); } private function onUp(e:TransformGestureEvent):void { var b:Sprite = Sprite(e.currentTarget); b.stopDrag(); } private function onZoom(e:TransformGestureEvent):void { e.stopImmediatePropagation(); this.con.scaleX = e.scaleX; this.con.scaleY = e.scaleY; } private function onRotate(e:TransformGestureEvent):void { e.stopImmediatePropagation(); this.con.rotatione += e.rotation; } } }













