"No Templates Proposals" Warning Error in Flash Builder
When hitting the Ctrl + SPACE bar I no longer receive my attributes or any of the code assist helping I got before. It turns out it actually is still there....hold the CTRL + hit the SPACEBAR two plus times.
I'm not sure why editing my Templates in Preferences now make it the default one of the cycle to show when doing a code edit, but so it goes.
Showing posts with label flashbuilder. Show all posts
Showing posts with label flashbuilder. Show all posts
Monday, April 11, 2011
Wednesday, November 24, 2010
Upload Image from Camera in Mobile Adobe AIR Android
For some reason I really struggled to upload a File (bytes) that I had in memory. It's easy to upload with the FileReference class, but that has an order of what methods can be called dependent on the browse() method being called. In this case, I have an Android <s:MobileApplication> app that uses the CameraUI class to take a picture and upload.
The key is taking the File that is returned, reading the bytes, and using a 3rd party library called MultipartURLLoader (which URLLoader can't do) to upload it.
private var myCam:CameraUI;
private var pictureFromCamera:File;
private var myByteArray:ByteArray;
/** This method you're used to seeing. The handler for when a user takes a picture */
protected function creationCompleteHandler(event:FlexEvent):void
{
if (CameraUI.isSupported)
{
myCam = new CameraUI();
myCam.addEventListener(MediaEvent.COMPLETE, onPictureTakenComplete, false, 0, true);
}
}
/**
* Handler for when user closes camera with a picture. MediaEvent (AIR only).
*/
private function onPictureTakenComplete(evt:MediaEvent):void
{
myByteArray = new ByteArray();
pictureFromCamera = evt.data.file;
//load file into bytes
var myFileStream:FileStream = new FileStream();
myFileStream.open(pictureFromCamera, FileMode.READ);
myFileStream.readBytes(myByteArray);
myFileStream.close();
}
/** method that uploads to server using a 3rd party lib */
public function upload_clickHandler(e:Event):void
{
var ml:MultipartURLLoader = new MultipartURLLoader();
ml.addEventListener(Event.COMPLETE, onUploadComplete, false, 0, true);
//add variables
ml.addVariable('title', titleField.text);
//add file bytes
ml.addFile(myByteArray, pictureFromCamera.name, 'file');
//submit
ml.load('http://justinbieberistheworst.com/upload.do');
}
For some reason I really struggled to upload a File (bytes) that I had in memory. It's easy to upload with the FileReference class, but that has an order of what methods can be called dependent on the browse() method being called. In this case, I have an Android <s:MobileApplication> app that uses the CameraUI class to take a picture and upload.
The key is taking the File that is returned, reading the bytes, and using a 3rd party library called MultipartURLLoader (which URLLoader can't do) to upload it.
private var myCam:CameraUI;
private var pictureFromCamera:File;
private var myByteArray:ByteArray;
/** This method you're used to seeing. The handler for when a user takes a picture */
protected function creationCompleteHandler(event:FlexEvent):void
{
if (CameraUI.isSupported)
{
myCam = new CameraUI();
myCam.addEventListener(MediaEvent.COMPLETE, onPictureTakenComplete, false, 0, true);
}
}
/**
* Handler for when user closes camera with a picture. MediaEvent (AIR only).
*/
private function onPictureTakenComplete(evt:MediaEvent):void
{
myByteArray = new ByteArray();
pictureFromCamera = evt.data.file;
//load file into bytes
var myFileStream:FileStream = new FileStream();
myFileStream.open(pictureFromCamera, FileMode.READ);
myFileStream.readBytes(myByteArray);
myFileStream.close();
}
/** method that uploads to server using a 3rd party lib */
public function upload_clickHandler(e:Event):void
{
var ml:MultipartURLLoader = new MultipartURLLoader();
ml.addEventListener(Event.COMPLETE, onUploadComplete, false, 0, true);
//add variables
ml.addVariable('title', titleField.text);
//add file bytes
ml.addFile(myByteArray, pictureFromCamera.name, 'file');
//submit
ml.load('http://justinbieberistheworst.com/upload.do');
}
Labels:
2.5,
adobe,
air,
burrito,
flash builder,
flashbuilder,
flex,
hero,
httpservice,
post,
uploading
Subscribe to:
Posts (Atom)