1

我怀疑我创建了一个应用程序来拍照,将其发送到数据库,然后在某个页面上打印。

当我让应用程序运行时,相机会正确显示。但它只在桌面上。当我在apk中打开fla并尝试在android上运行时,面向相机出现在水平方向。

我怎么解决这个问题?

代码在这里:

import com.adobe.images.JPEGEncoder;

var video:Video;
var camera:Camera;

var imgBA:ByteArray;
var imgBD:BitmapData;
var imgBitmap:Bitmap;

var phpPath:String;
var jpgEncoder:JPEGEncoder;
var sendHeader:URLRequestHeader;
var sendReq:URLRequest;
var sendLoader:URLLoader;

var imagePath:String;


setupCamera(430,500);

var inicializado:Boolean=false;

status_txt.text="esperando coordenadas";
var geolocationmarcelinho:MarcelinhoGeolocation=new MarcelinhoGeolocation(geoUpdate);

function geoUpdate(lat:Number,lon:Number)
{
if(inicializado)
{
lat_txt.text=lat+"";
lon_txt.text=lon+"";
}
else
{
setupApplication();
lat_txt.text=lat+"";
lon_txt.text=lon+"";
if(lat==-1)
{
status_txt.text="sem geolocation";
}
else
{
status_txt.text="pode usar!";
}
inicializado=true; 
}


}

//setupApplication();

function setupCamera(w:int,h:int):void {
try {
camera = Camera.getCamera();
} catch(e:Error) {
status_txt.text="camera não conectada!";
trace("No Camera detected!");
}

camera.addEventListener(StatusEvent.STATUS, camStatusHandler);
camera.setMode(w,h,stage.frameRate);

video = new Video(w,h);
video.attachCamera(camera);
addChild(video);
}

function camStatusHandler(event:StatusEvent):void {
// Camera.Muted or Camera.Unmuted -> User's security
trace(event.code);
}

function setupApplication():void {
shotBtn.addEventListener(MouseEvent.CLICK, createSnapshot);
removeBtn.addEventListener(MouseEvent.CLICK, removeSnapshot);
sendBtn.addEventListener(MouseEvent.CLICK, sendImage);



jpgEncoder = new JPEGEncoder(90);

}

function createSnapshot(event:MouseEvent):void {
imgBD = new BitmapData(video.width,video.height);
imgBD.draw(video);

imgBitmap = new Bitmap(imgBD);
addChild(imgBitmap);

shotBtn.removeEventListener(MouseEvent.CLICK, createSnapshot);
}

function removeSnapshot(event:MouseEvent):void {
removeChild(imgBitmap);
comentario_txt.text="";
status_txt.text="pode usar!";
shotBtn.addEventListener(MouseEvent.CLICK, createSnapshot);
}

function sendImage(event:MouseEvent):void {
phpPath = "http://celoweb.com.br/app/img_aplicativo/upload.php?comentario=qualquercoisa&latitude=34&longitude=-45"
+comentario_txt.text+"&latitude="+lat_txt.text+"&longitude="+lon_txt.text;

sendHeader = new URLRequestHeader("Content-type","application/octet-stream");
sendReq = new URLRequest(phpPath);
sendReq.requestHeaders.push(sendHeader);
sendReq.method = URLRequestMethod.POST;

sendLoader = new URLLoader();
sendLoader.addEventListener(Event.COMPLETE,imageSentHandler);


imgBA = jpgEncoder.encode(imgBD);
sendReq.data = imgBA;
sendLoader.load(sendReq);
}

function imageSentHandler(event:Event):void {
var dataStr:String = event.currentTarget.data.toString();
var resultVars:URLVariables = new URLVariables();
resultVars.decode(dataStr);

imagePath = "http://" + resultVars.base + "/" + resultVars.filename;
status_txt.text="Uploaded to: " + imagePath;
trace("Uploaded to: " + imagePath);
sendLoader.removeEventListener(Event.COMPLETE,imageSentHandler);
}
4

1 回答 1

0

同意你的问题有点不清楚,但猜测......

要旋转图像,您将使用: imgBitmap.rotation = 90;

或翻转:

imgBitmap.scaleX = -1;

于 2012-12-05T07:42:07.950 回答