2013-05-05 56 views
0

我最近将AIR 3.7覆盖到Flex 4.9.1 SDK中。我创建的iOS应用程序与3.4(我创建它)完美地工作。部分应用程序是拍摄照片或从相机胶卷中获取(并保存压缩版本)。然而,在3.7版本中,一旦MediaEvent.Complete代码被调用(代码位于下方),任何想法,我是否需要添加一个loadercontext?使用AIR 3.4创建的应用程序在AIR中不起作用3.7

protected function onComplete(event:MediaEvent):void { 


      //Busy Indicator 

      bi = new UploadAlert(); //upload Alert is a component I created to display a Busy indicator 
      bi.x = this.width/2 - 150; 
      bi.y = this.height/2 - 150; 

      //Get number of elements 
      allElements = this.numElements; 



      this.addElementAt(bi, allElements); 





      var cameraUI:CameraUI = event.target as CameraUI; 


      var mediaPromise:MediaPromise = event.data; 

      var mpLoader:Loader = new Loader(); 
      mpLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMediaPromiseLoaded); 

      mpLoader.loadFilePromise(mediaPromise); 


     } 

     private function onMediaPromiseLoaded(e:Event):void 
     { 
      var mpLoaderInfo:LoaderInfo = e.target as LoaderInfo; 
      mpLoaderInfo.removeEventListener(Event.COMPLETE, onMediaPromiseLoaded); 

      this.imageProblem.source = mpLoaderInfo.loader; 






       var bitmapDataA:BitmapData = new BitmapData(mpLoaderInfo.width, mpLoaderInfo.height); 
       bitmapDataA.draw(mpLoaderInfo.content,null,null,null,null,true); 



       var bitmapDataB:BitmapData = resizeimage(bitmapDataA, int(mpLoaderInfo.width/4), int(mpLoaderInfo.height/ 4)); // function to shrink the image 





       var c:CameraRoll = new CameraRoll(); 
       c.addBitmapData(bitmapDataB); 

       var now:Date = new Date(); 
       var f:File = File.applicationStorageDirectory.resolvePath("IMG" + now.seconds + now.minutes + ".jpg");          
       var stream:FileStream = new FileStream() 
       stream.open(f, FileMode.WRITE);           

       // Then had to redraw and encode as a jpeg before writing the file 


       var bytes:ByteArray = new ByteArray(); 
       bytes = bitmapDataB.encode(new Rectangle(0,0, int(mpLoaderInfo.width/4) , int(mpLoaderInfo.height/4)), new JPEGEncoderOptions(80), bytes); 




       stream.writeBytes(bytes,0,bytes.bytesAvailable); 
       stream.close(); 




      imagefile = f; 
      deleteFlag = 1; 

      this.removeElementAt(allElements); 

      this.btnRotate.enabled = true; 
      this.btnDelete.enabled = true; 
     } 
+0

如果应用程序挂起;你怎么知道这是在这个代码?你有没有在调试模式?哪一行代码导致了这个问题? – JeffryHouser 2013-05-05 12:24:49

+0

好吧调试会话告诉我这个:VerifyError:错误#1014:类flash.display :: JPEGEncoderOptions无法找到 – 2013-05-07 00:53:47

回答

2

好,所以问题不在我的代码。实际上,当我覆盖AIR 3.7时,air-config.xml,flex-config.xml和airmobile-config.xml的文件仍然针对的是Flash播放器的版本过低。它是11.1和swf版本14.

它应该分别是11.5和18。一旦我改变了这些文件,它就完美了!

+0

我很高兴你找到答案,并回来发布它。从我+1。您应该能够将此答案标记为“已接受” – JeffryHouser 2013-05-07 02:19:56

+0

谢谢Reboog711 – 2013-05-07 12:13:43