我喜欢很多其他人正在尝试使用 zxing actionscript 库为我的 Flex Mobile 应用程序实现条形码扫描仪。我的问题是,让相机在实际设备上正确显示我有一段时间了。使用网络摄像头在桌面上运行应用程序可以很好地显示视频源。以下是我在 Galaxy Nexus 和 Nexus 7 上获得的类似信息。
我一直主要研究这个例子,但也从其他网站获得了建议: http ://www.remotesynthesis.com/post.cfm/adding-a-qr-code-reader-in-flex-on-安卓
一切都会为视频对象产生相同的古怪提要。有人知道我能做些什么来纠正这个吗?
这是我当前形式的代码,此时只是试图获得清晰的图像(还没有条形码垃圾):
扫描仪2.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:bs="com.expologic.barcodescanner"
title="Scanner" creationComplete="init(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.core.UIComponent;
import com.expologic.barcodescanner.BarcodeScanner;
private var bs:BarcodeScanner;
private function init(e:Event):void {
bs = new BarcodeScanner();
bs.horizontalCenter = 0;
bs.verticalCenter = 0;
bs.height = 480;
bs.width = 640;
addElement(bs);
//To add a target to the center of the screen
var uic:UIComponent = new UIComponent();
this.addElement(uic);
uic.width = uic.height = 275;
uic.graphics.lineStyle(3,0xFF0000);
uic.graphics.drawRect(0,0,275,275);
uic.horizontalCenter = uic.verticalCenter = 0;
}
]]>
</fx:Script>
</s:View>
条码扫描仪.as
package com.expologic.barcodescanner
{
import flash.events.Event;
import flash.media.Camera;
import flash.media.Video;
import spark.core.SpriteVisualElement;
public class BarcodeScanner extends SpriteVisualElement
{
private var _video:Video;
public function BarcodeScanner()
{
this.height = 480;
this.width = 640;
addEventListener(Event.ADDED_TO_STAGE, _addToStage);
}
private function _addToStage(e:Event):void {
_setupCamera();
}
private function _setupCamera():void
{
if(!_video)
{
_video = new Video(640, 480);
addChild(_video);
}
if(Camera.isSupported)
{
var cam:Camera = Camera.getCamera();
cam.setQuality(0, 100);
cam.setMode(640, 480, 30, false);
_video.attachCamera(cam);
}
}
}
}