2014-01-24 61 views

回答

0

在這個邏輯我張貼谷歌驗證碼圖像。捕獲驗證碼圖像並保存。

protected function captchaLoadComplete():void 
      { 
            var fileStream:FileStream = new FileStream(); 


enter code here 


        // Capture captcha image 
        var imageBitmapData:BitmapData = ImageSnapshot.captureBitmapData(WBCaptcha); 

        // Encode captcha image into JPEG format 
        var oJpg:JPEGEncoder = new JPEGEncoder();    
        var data:ByteArray = oJpg.encode(imageBitmapData); 

        // *** Here load the captcha image in MAC os *** 
        if((Capabilities.os.indexOf("Mac") >= 0)) 
        { 
         //*** Save the downloaded file without generate browser popup *** 
         fileStream.open(new File(File.applicationStorageDirectory.nativePath+"/temp.jpg"),FileMode.WRITE); 

         fileStream.writeBytes(data, 0, data.length); 

        }else if((Capabilities.os.indexOf("Windows") >= 0)) 
        {     
         // Save the Capture image without generate browser popup 
         fileStream.open(new File(File.applicationStorageDirectory.nativePath+"\\temp.jpg"),FileMode.WRITE);    
         fileStream.writeBytes(data, 0, data.length); 

         // load Capture image in window os 
         imgCaptcha.source = File.applicationStorageDirectory.nativePath +"\\"+ "temp.jpg"; 

        } 
        timerforLoadPage = new Timer(5000, 0); 
        timerforLoadPage.addEventListener(TimerEvent.TIMER, imageLoadComplete); 
        timerforLoadPage.start(); // Start timer 

          }