1.双手移动事件:
import flash.events.TransformGestureEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
var s:Sprite = new Sprite();
addChild(s);
Multitouch.inputMode = MultitouchInputMode.GESTURE;
s.addEventListener(TransformGestureEvent.GESTURE_PAN,panh);
2.双手缩放事件:
s.addEventListener(TransformGestureEvent.GESTURE_ZOOM,zoomh);
3.地理位置
[code]
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.events.TransformGestureEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.text.TextField;
import flash.sensors.Geolocation;
import flash.events.GeolocationEvent;
import flash.events.StatusEvent;
public class Pic extends Sprite {
[Embed(source="test.jpg")]
private var MiniImage:Class;
var t:TextField;
var geo:Geolocation;
public function Pic() {
// constructor code
super();
var b:Bitmap = new MiniImage();
var s:Sprite = new Sprite();
s.addChild(b);
addChild(s);
Multitouch.inputMode = MultitouchInputMode.GESTURE;
s.addEventListener(TransformGestureEvent.GESTURE_PAN,panh);
s.addEventListener(TransformGestureEvent.GESTURE_ZOOM,zoomh);
t = new TextField();
addChild(t);
if(Geolocation.isSupported)
{
geo = new Geolocation();
geo.setRequestedUpdateInterval(500);
geo.addEventListener(GeolocationEvent.UPDATE,uh);
geo.addEventListener(StatusEvent.STATUS,sh);
}else{
t.text ="no gps";
}
}
private function panh(e:TransformGestureEvent):void
{
(e.target as Sprite).x+=e.offsetX;
(e.target as Sprite).y+=e.offsetY;
}
private function zoomh(e:TransformGestureEvent):void
{
(e.target as Sprite).scaleX*=e.scaleX;
(e.target as Sprite).scaleY*=e.scaleY;
}
private function uh(e:GeolocationEvent):void
{
t.appendText(e.latitude+","+e.longitude);//正纬度北,正经度东
}
private function sh(e:StatusEvent):void
{
if(geo.muted)
{
t.text = "no gps give";
}
}
}
}[/code]