26. Multi-touch
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
27. Multi-touch
• Similar to multiple mouse events
• Both multi-touch events and gesture events
• Requires multi-touch hardware (Pre y obvious)
• Amount of touch points only limited by the hardware
• Supported in AIR 2 and FP10.1 (if the browser supports multi-
touch)
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
28. Multi-touch / Gestures
public function init():void
{
Multitouch.inputMode = MultitouchInputMode.GESTURE;
logo.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onRotate );
logo.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom );
}
private function onRotate(evt:TransformGestureEvent):void
{
// pssst... you should try rotationX or Y
logo.rotation += evt.rotation;
}
private function onZoom(evt:TransformGestureEvent):void
{
logo.scaleX *= evt.scaleX;
logo.scaleY *= evt.scaleY;
}
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
29. Screen
orientation
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
30. Screen orientation
• Tells you if your app is viewed in landscape or portrait mode
• Reformat your application based on the orientation
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
31. Screen orientation
import flash.events.StageOrientationEvent;
stage.addEventListener("orientationChange", orientationChangedHandler);
function orientationChangedHandler(event:StageOrientationEvent)
{
dummy.width = stage.stageWidth - 20;
dummy.height = stage.stageHeight - 20;
}
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
32. Accelerometer
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
33. Accelerometer
• Different from screen rotation
• Converts movement in to three dimensional coordinates
• X, Y and Z acceleration
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
34. Accelerometer
var accelerometer = new Accelerometer();
accelerometer.addEventListener(AccelerometerEvent.UPDATE, onMove);
accelerometer.setRequestedUpdateInterval(40);
function onMove(event:AccelerometerEvent):void
{
var ax = event.accelerationX*20;
var ay = (event.accelerationY*20)*-1;
var az = event.accelerationZ;
football.x += ax;
football.y += ay;
football.scaleX = football.scaleY = az;
}
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
35. Geo location
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
36. Geo location
• Get the device location coordinates
• Latitude, longitude, altitude, speed and heading
• Build your own Tom Tom ;-)
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351
37. Geo location
import flash.sensors.Geolocation;
import flash.events.GeolocationEvent;
var geo = new Geolocation();
geo.setRequestedUpdateInterval(1000);
geo.addEventListener(GeolocationEvent.UPDATE, onTravel);
function onTravel(event:GeolocationEvent):void
{
long.text = event.latitude.toString();
lat.text = event.longitude.toString();
heading.text = event.heading.toString();
speed.text = event.speed.toString();
hacc.text = event.horizontalAccuracy.toString();
vacc.text = event.verticalAccuracy.toString();
}
®
Copyright 2010 Adobe Systems Incorporated. All rights reserved. #adobeAUG XL351