Question

Can anyone point me to any tutorials that might help in creating a basic Away 3d app that supports swipe gestures? I want to simply enable a user to rotate a 3d cube by swiping it.

Was it helpful?

Solution 2

Away3D has no built-in support for gestures. You will need to integrate Flash's gestures (painful) or use a library like Gestouch

OTHER TIPS

I think you'd use something like this:

private var _cube:ObjectContainer3D;
private var _startTouchX:Number;

public function ThreeDimensionViewer(){
    _cube = new ObjectContainer3D(INSERT CUBE HERE);
    var cam:Camera3D = new Camera3D();
    var scene:Scene3D = new Scene3D();
    scene.addChild(cam);
    scene.addChild(_cube);
    var view:View3D = new View3D(scene, cam);

    view.addEventListener(TouchEvent.TOUCH_BEGIN,startTouch);
}
private function startTouch(e:TouchEvent):void {
    _startTouchX = e.stageX;
    view.removeEventListener(TouchEvent.TOUCH_BEGIN,startTouch);
    view.addEventListener(TouchEvent.TOUCH_MOVE,moveCube);
    view.addEventListener(TouchEvent.TOUCH_END,stopTouch);
}
private function moveCube(e:TouchEvent):void {
    _cube.rotateY = _startTouchX - e.stageX;
}
private function stopTouch(e:TouchEvent):void {
    view.addEventListener(TouchEvent.TOUCH_BEGIN,startTouch);
    view.removeEventListener(TouchEvent.TOUCH_MOVE,moveCube);
    view.removeEventListener(TouchEvent.TOUCH_END,stopTouch);
}

Pretty sure you'd use TouchEvent (BEGIN, MOVE, END) and calculate like you would normally using a MouseEvent. I haven't tested this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top