Skip to main content
Known Participant
December 16, 2011
Question

Rotate in multitouch does not work properly

  • December 16, 2011
  • 1 reply
  • 825 views

Hello:

When I use the code below to rotate a image with multitouch screen I rotate but on a corner. Can anyone tell me how to rotate in the center of the image?

Thank you very much.

import flash.display.StageDisplayState;

import flash.display.StageScaleMode;

import flash.display.StageAlign;

import flash.events.Event;

import flash.events.MouseEvent;

import flash.display.Sprite;

import flash.events.TransformGestureEvent;

import flash.ui.Multitouch;

import flash.ui.MultitouchInputMode;

Multitouch.inputMode = MultitouchInputMode.GESTURE;

/*stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

stage.scaleMode = StageScaleMode.NO_SCALE;*/

stage.align = StageAlign.TOP_LEFT;

var con:Sprite = new Sprite();

con.x = stage.stageWidth * .5;

con.y = stage.stageHeight * .5;

addChild(con);

var b:Sprite = Sprite(new f1());  // my image

b.x=-135;

b.y=-400;

b.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onRotate);

con.addChild(b);

function onRotate(e:TransformGestureEvent):void

{

    var b:Sprite = Sprite(e.currentTarget);

    b.rotation +=  e.rotation;

}

This topic has been closed for replies.

1 reply

_spoboyle
Inspiring
December 16, 2011

1) you can either rotation con rather than sprite (but this will rotate all DisplayObjects in con

2) replace

var b:Sprite = Sprite(new f1());  // my image

with

var b:Sprite = new Sprite();

var image:Sprite = Sprite(new f1());

image.x = -image.width/2;

image.y = -image.height/2;

b.addChild(image);

P.S. rotation is working properly just not the way you expected

anjemalo1Author
Known Participant
December 16, 2011

Thank you very much.

I get the same result.

I cannot rotate with two finger in the center of image.

Do you know why?