Reputation: 72
I recently overlaid AIR 3.7 into the Flex 4.9.1 SDK. An iOS app I created works perfectly with 3.4 (which I created it with). Part of the app is to either take a picture or get it from the Camera Roll (and save a compressed version) However, in 3.7 the app hangs once the MediaEvent.Complete code is called (code Below) Any Ideas, do I need to add a loadercontext?
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;
}
Upvotes: 0
Views: 289
Reputation: 72
OK so the problem was NOT with my code. It WAS in fact when I overlaid AIR 3.7, The files for air-config.xml, flex-config.xml, and airmobile-config.xml were still targeting too low of version of flash player. It was 11.1 and swf version 14.
It should have been 11.5 and 18 respectively. Once I changed these files, it worked perfectly!
Upvotes: 2