我要建一个应用程序使用ActionScript 3.0在我的Flash Builder中。这是一个后续问题this问题,它的工作原理,但是当我拍摄照片,拍摄的图像旋转到左边。我怎么能检查哪些方式,用户拿着手机?然后呢code做我使用到它的相应位置,将图像旋转?
I'm building an App with actionscript 3.0 in my Flash builder. This is a followup question to this question, It works but when I take the picture, the image comes out rotated to the left. how can I check which way the user is holding the phone? and then what code do I use to rotate the image to it's corresponding place?
在先进的感谢!
编辑: 我使用这个code旋转图像,但它似乎只旋转图像显示没有图像文件,任何想法?
I'm using this code to rotate the image, but it seems to only rotate the image being displayed not the image file, any ideas?
var mat:Matrix = new Matrix();
mat.translate(-W/2, -H/2);
mat.rotate(Math.PI/2);
mat.translate(+W/2, +H/2);
mat.concat(myObj.transform.matrix);
myObj.transform.matrix = mat;
〜MYY
您可以使用 Stage.deviceOrientation 或 Stage.orientation *,以确定哪种方式轮手机。
You can use Stage.deviceOrientation or Stage.orientation* to determine which way round the phone is.
*不知道这一件作品在iOS
*not sure if this one works on iOS
时它的BitmapData结果本身要旋转(即创建一个新的BitmapData旋转的图像),或者只需旋转显示列表中的一个位图?
Is it the BitmapData result itself that you want to rotate (ie create a new BitmapData with rotated image) or just rotate a Bitmap on the display list?
编辑:
好吧,继承人一些code旋转BitmapData对象:
Ok, heres some code to rotate a BitmapData object:
function rotateBitmapData(angle:int, source:BitmapData):BitmapData
{
var newWidth:int = source.rect.width;
var newHeight:int = source.rect.height;
if (angle==90 || angle==270)
{
newWidth = source.rect.height;
newHeight = source.rect.width;
}
var newBmd:BitmapData = new BitmapData(newWidth, newHeight, source.transparent);
var tx:Number = 0;
var ty:Number = 0;
if (angle==90 || angle==180)
{
tx = newWidth;
}
if (angle==180 || angle==270)
{
ty = newHeight;
}
var matrix:Matrix = new Matrix();
matrix.createBox(1, 1, Math.PI*angle/180, tx, ty);
newBmd.draw(source, matrix);
return newBmd;
}
角度应该是0,90,180或270这将返回指定角度旋转的新的BitmapData对象。
angle should be 0,90,180 or 270. It will return a new BitmapData object rotated by specified angle.
上一篇:AS3鼠标滚轮反鼠标、滚轮