2013-01-19 45 views
1

我喜歡很多其他人試圖爲我的Flex Mobile應用程序使用zxing actionscript庫實現條形碼掃描器。我的問題是,我需要一段時間才能讓相機在實際設備上正確顯示。使用網絡攝像頭在桌面上運行該應用程序可以顯示視頻源。下面是我得到我的Galaxy Nexus和Nexus的7在Flex Mobile Framework和Android中使用Camera類

on the galaxy nexus

我一直主要工作過這個例子中的相似,但已採取從其他網站的建議,以及: http://www.remotesynthesis.com/post.cfm/adding-a-qr-code-reader-in-flex-on-android

所有內容都會產生與視頻對象相同的古怪提要。任何人都知道我能做些什麼來糾正這個問題?

這是我目前的形式代碼只是試圖(但沒有條形碼的垃圾)在這一點上得到清晰的畫面:

scanner2.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> 

BarcodeScanner.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); 
       } 
      } 

     } 
    } 

回答

3

嘗試設置在app.xml中,這解決了這個問題對我來說<renderMode>direct</renderMode>,我也使用的Galaxy Nexus。 Registers Joko

+1

啊!這工作!我確實發現回到設備上的AIR 3.1也解決了這個問題,當然Android也希望保持自動更新AIR。有人應該告訴Adobe在Tour de Flex移動應用程序中這樣做,因爲它也出現在相機示例中! –

+0

感謝它的作品。 – ElitCenk

1

我不明白確切的問題,但嘗試添加下列鏈接中列出的權限:

zxing barcode scanner autofocus issue on reading second qr code

+0

已經有相機和自動對焦作爲權限,但我會在今晚晚些時候嘗試其餘的。 –

+0

這似乎不能解決問題。仍然是灰色的混亂。 –

+0

設置相機權限爲我解決這個問題,謝謝 – Anas