Re: [flexcoders] blackberry playbook cameraUI, cameraRoll problems

Thursday, January 12, 2012

 

BTW If you are getting errors loading in media from Blackberry Playbook make sure to enable the permission "access_shared". Otherwise you will get a Error 3003.

2011/7/23 Csomák Gábor <csomakk@gmail.com>
 

i use panels instead of titlewindows. it works for popups (check desktop version at www.sharedboard.net, and a tablet version on bberry or android)

by the way, the solution for the first letter: cameraroll is not supported in bberry, so it goes to the else {} part, where it needs permission to access shared media. thats it :)

On Fri, Jul 22, 2011 at 10:56 AM, John Fletcher <fletchgqc@gmail.com> wrote:
 
Thanks for that. In my case I'm looking for something more comprehensive, I have an existing Air desktop app with much code that in principle was written in AS3 and Skins to be re-used but it references things that don't exist in Mobile Projects. For example TitleWindows (popups), Mobile projects complain that they don't have this component. So now we have to re-architect things a bit to figure out how to do what we want to do whilst we maximise code sharing.
 
John

2011/7/20 Csomák Gábor <csomakk@gmail.com>
 
its a simple mobile project.. i tick all mobile os-es (bberry, android, iphone).
there are some parts (like menu button) where i have an if (qnx||android) removeMenuBtn() like functions. (see below for code) (because on bberry, swipe_down is the menu, and android has a menu key)

the only trick there is a bug in the PlayBook swipe_down with the simulator, so i have to toggle the // in the beginning of this line, when releasing:
private function deviceIsPlaybook():void {
    // QNXApplication.qnxApplication.addEventListener(QNXApplicationEvent.SWIPE_DOWN, swipeDown);//errort dob :S
    hgroup.removeElement(menuBtn);
}

So this is how you check system:

if (flash.system.Capabilities.version.substr(0,3) == "IOS"){ //WIN, MAC, UNIX, AND
//iOS
trace("device recognised as iOS device")
} else if (flash.system.Capabilities.version.substr(0,3) == "QNX"){
//Blackberry
trace("device recognised as PlayBook")
try {
  deviceIsPlaybook() //this must be a separate function, otherwise it won't catch the simulator error
  } catch(error:Error) { }

} else if (flash.system.Capabilities.version.substr(0,3) == "AND"){
//Android
trace("device recognised as Android device")
hgroup.removeElement(menuBtn);
  //listen for menu key elsewhere!
} else {
//Desktop
trace("device recognised as desktop")
}


On Wed, Jul 20, 2011 at 10:25 AM, John Fletcher <fletchgqc@gmail.com> wrote:
 
May I ask what technique you are using for code sharing between platforms? Currently a hot topic in my opinion, I saw an interesting video from Adobe Max where some Adobe devs talked about it, apart from that there are no resources or recommendations out there.
 
John

2011/7/18 Csomák Gábor <csomakk@gmail.com>
 
Hi!
I'm developing Shared Board (sharedboard.net) for multiple platforms: iPad, Android, Playbook, and desktop.
I have 2 problems with PlayBook, what runs flawlessly on iPad: (I've included the working the working desktop solutions, those are the else parts)

First is when I want to add an Image to the visCompHand.toMove MC with the cameraRoll Browse for Image function: on iPad, desktop it works perfect, but on PlayBook, if I select a picture, it doesn't load it to the MC.

if(CameraRoll.supportsBrowseForImage){
cameraRollom=new CameraRoll();
cameraRollom.addEventListener(MediaEvent.SELECT, onMediaSelect);
cameraRollom.browseForImage()

function onMediaSelect(e:MediaEvent):void{
var promise:MediaPromise=e.data
loader.loadFilePromise(promise)
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageContentLoaderComplete);
FlexGlobals.topLevelApplication.homeView.addElement(visCompHand);
visCompHand.toMove.addChild(loader);
}
  } else {
var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png;*.swf;");
  var imageFile:File = new File();
imageFile.browseForOpen("Select an Image", [imagesFilter]);
imageFile.addEventListener(Event.SELECT, imageSelected2);

function imageSelected2(e:Event):void{
     imageSelected(e.target as File);
}
}

Second is when I try to save the board MC as picture to cameraRoll. On iPad it works, on Playbook it fails:
if(CameraRoll.supportsAddBitmapData){
cameraRollom=new CameraRoll();
var imagesn:ImageSnapshot=ImageSnapshot.captureImage(FlexGlobals.topLevelApplication.homeView.board)
var loader : Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);
loader.loadBytes(imagesn.data);

function getBitmapData(e:Event):void{
var content:*=loader.content;
var image:Bitmap = Bitmap(content);
/** get the bitmapdata **/
var bitmap:BitmapData = image.bitmapData
cameraRollom.addBitmapData(bitmap)
  }
} else {
var image:ImageSnapshot = ImageSnapshot.captureImage(FlexGlobals.topLevelApplication.homeView.board, 300, new PNGEncoder());
var file:FileReference = new FileReference();
var date:Date=new Date();
var month:String=date.getMonth()+1+""
if (date.getMonth()<9) month="0"+month;
var day:String=date.getDate()+"";
if(date.getDate()) day="0"+day
file.save(image.data, "SharedBoard"+date.getFullYear()+month+day+".png");
}

I also have a bonus question:
I want to add picture as in 1st problem, but from the webcam/camera, and one that runs on neither platform:
if(CameraUI.isSupported){
cameraUIom=new CameraUI()
cameraUIom.addEventListener(MediaEvent.COMPLETE, onCameraComplete)
cameraUIom.launch(MediaType.IMAGE)
}

  Thanks for any help!
Gabor 





__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

0 comments:

Post a Comment