Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 382
Registered: ‎05-19-2008
My Device: BlackBerry Torch
My Carrier: AT&T

File.BrowseForSave() STILL BROKEN!

You would think that this would have been fixed with the 1.0 release. I mean THIS IS BASIC FUNCTIONALITY. Sadly, it's still broken.

 

The save browse dialog simply pops a dialog asking for your filename. You can't change paths or anything.

 

The load browse dialog is MUCH nicer. It allows you to choose which subfolder to view, such as pictures, documents, etc. It appears that CameraRoll.browseForImage() uses the same dialog as File.browse(), which probably explains why it works!

 

But, save is still broken. Furthermore, the old ways that we've used to work around the issues don't work either.

 

private function save(e:MouseEvent):void
{
	trace("saving");
						
	var myFile:File = File.documentsDirectory;
	myFile.browseForSave("Save Image");
	myFile.addEventListener(Event.SELECT, chooseSave);
}

 

private function chooseSave(e:Event):void
{	
	var sel:File = e.target as File;
	trace (sel.nativePath); 
}

 

 

Running this app and entering "test" into the browse dialog shows a trace output of:

/accounts/1000/appdata/<appdir>/shared/documentstest

 

 

It appears that the name is mangled in what appears to be a forgotten slash when the name and path are appended internally. In the past, I've worked around the broken browse dialogs by only getting the filename from e.target and then recreating the path.

 

 

 

var name2:File = File.documentsDirectory.resolvePath(sel.name);

 

 

This approach no longer works though! It's not hard to work around using some stupid simple string manipulation, but, if you are working with images, I'd just use the CameraRoll.

 

 

var index:int = sel.nativePath.indexOf("documents");
var newPath:String;
newPath = sel.nativePath.substr(0,index+9)+"/"+sel.nativePath.substring(index+9,sel.nativePath.length);

 

 

 

 

Bill
-------------------------------------------
Check out my book on BlackBerry Development for Java.
And my other really really old book
My Apps: FlashKids
BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: File.BrowseForSave() STILL BROKEN!

This has been fixed in the 1.0.3 version of the OS. Note that it will still not work in the simulator until the next update.