reducing camera roll size
what do i need to put into my code here that will reduce the size of the image I load onto my stage from the camera roll? I change the physical dimensions but its just obviously still loading the larger imagine into the bitmapdata. Im finding if the user loads a huge file it totally crashes the app. I want to reduce it to 1024px on the width
function checkPermission (e:Event=null):void
{
if (CameraRoll.permissionStatus != PermissionStatus.GRANTED) {
cameraRoll2.addEventListener(PermissionEvent.PERMISSION_STATUS, function (e: PermissionEvent): void {
if (e.status == PermissionStatus.GRANTED) {
launchCamera()
} else {
// permission denied
}
});
try {
cameraRoll2.requestPermission();
} catch (e: Error) {
// another request is in progress
}
} else {
launchCamera()
}
}
function launchCamera():void {
if (CameraRoll.supportsBrowseForImage) {
_roll = new CameraRoll();
_roll.browseForImage();
_roll.addEventListener(MediaEvent.SELECT, onSelect);
_roll.addEventListener(Event.CANCEL, onCancel);
} else {
}
}
function onSelect(event:MediaEvent):void {
activityDialog = Dialog.service.create(
new ActivityBuilder()
.setTheme( new DialogTheme( DialogTheme.DEVICE_DEFAULT_DARK ))
.build()
);
activityDialog.show();
_roll.removeEventListener(MediaEvent.SELECT, onSelect);
_roll.removeEventListener(Event.CANCEL, onCancel);
var imagePromise:MediaPromise = event.data;
_load = new Loader();
if (imagePromise.isAsync) {
_load.contentLoaderInfo.addEventListener( Event.COMPLETE, imageLoaded );
_load.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, imageLoadFailed );
_load.loadFilePromise(imagePromise);
} else {
_load.loadFilePromise( imagePromise );
sourcePhoto="local"
}
}
function imageLoaded( evt:Event ):void {
if(myBitmapData==null)
{
}
else
{
myBitmapData.dispose()
myBitmapData = null
target_mc.removeChildAt(0)
}
evt.target.content.width = 900;
evt.target.content.scaleY = evt.target.content.scaleX;
if(evt.target.content.height>700)
{
evt.target.content.height = 700;
evt.target.content.scaleX = evt.target.content.scaleY;
}
if(evt.target.content.height<700)
{
evt.target.content.y = (700-evt.target.content.height)/2
}
if(evt.target.content.width<900)
{
evt.target.content.x = (900-evt.target.content.width)/2
}
target_mc.addChild(evt.target.content); //add the content
myBitmapData = Bitmap(LoaderInfo(evt.target).content).bitmapData;
trace(myBitmapData.width);
trace(myBitmapData.height);
}
function imageLoadFailed( event:Event ):void {
}
function onCancel(event:Event):void {
_roll.removeEventListener(MediaEvent.SELECT, onSelect);
_roll.removeEventListener(Event.CANCEL, onCancel);
}
