Saturday, February 19, 2011

Blackberry Playbook error using AIR StageWebView

Here was a crazy error on the latest Blackberry Playbook simulator (0.9.3). If you reference a non-existent file or image, it throws this error:

Error #2044: Unhandled ErrorEvent:. text=Couldn't read a file:// file

It was no fun trying to figure out where this bug was coming from! :-(

Thursday, February 3, 2011

Facebook Places throws oAuth error: "The table you requested does not exist"

Just did a great workshop with Conrad Fuhrman who demonstrated his ARTi application, an augmented reality app build with Titanium. It also uses a new Titanium Facebook module that allows you to connect to Facebook using oAuth. However, when I tried to run the code sample I kept getting this oAuth error:

entries =>
{contents = "type"} = {contents = "OAuthException"}
{contents = "message"} = {contents = "(#603) The table you requested does not exist"}
}
}

After a google search this post turned up which explained it all. It turns out that Facebook Places does not work outside of the US, and since I was trying to access it from Barbados, it was failing.

Friday, January 14, 2011

Monday, January 10, 2011

Creating scrollable divs on a Mobile device

On mobile devices the scroll property cannot be set for divs on the page since the page itself is scrollable. Google has released a possible workaround that I am trying to get working. It involves disabling the scroll property of the document and animating the div in response to touch events:

http://code.google.com/mobile/articles/webapp_fixed_ui.html

Update: I just found the YUI Scrollview and (after figuring out a critical step to get the scrollbars to work) its awesome!

http://developer.yahoo.com/yui/3/scrollview/

The problem I ran into was how to get the scrollbars to show up. It turns out that the documentation does not include the need to attach a "yui-skin-sam" style to the container that holds the scrollable div. So in order to make it work here is a very simple example:

http://pastie.org/1454114

Friday, January 7, 2011

Getting local HTML file to load in the Blackberry Playbook

I've been trying out the SDK for the Blackberry Playbook and one thing that was stumping me was how to load a local HTML file using the StageWebView in AIR 2.5.

I placed the local HTML file in the root folder (in the same folder as the .mxml file) and tried to load it this way:

**************

import flash.media.StageWebView;

private var webView:StageWebView = null;

private function init():void{
// get the file location
var f:File = new File("app:/map-simple.html");

webView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight );
webView.loadURL( f.url );

}

**************

...but it didn't work. Fortunately, I stumbled on this post by Mike Chambers that explains a workaround and recoded the app this way:

**************

import flash.media.StageWebView;

private var webView:StageWebView = null;

private function init():void{

var fPath:String = new File(new File("app:/map-simple.html").nativePath).url;

webView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight );
webView.loadURL( f.url );
}

***************

This works great!

By the way, I also tried to use the QNXStageWebView in the latest Blackberry SDK but the FlashBuilder (Burrito) compiler gave me the following error:

A file found in a source-path must have an externally visible definition. If a definition in the file is meant to be externally visible, please put the definition in a package.

This apparently has been faced by other developers (see here) using the QNXStageWebView and the Blackberry support boards indicate that this is a beta Class and has numerous issues -- so I decided not to try to find a workaround (which seems to involve digging up an older swc file).

One caution, the AIR StageWebView is also still in beta and does not currently allow for communicating between the base app and the StageWebView object. In my case however, I am just trying to get a fully working HTML app to run on the Playbook.

Thursday, November 11, 2010

Convert string with carriage returns to one line in php

I have a database string containing new lines characters (\n) and needed to print it out with no linebreaks -- since it was being printed as a javascript variable. This script does the trick:

$input = trim( preg_replace( '/\s+/', ' ', $input ) );

courtesy: http://www.codingforums.com/showthread.php?t=137009

Sunday, November 7, 2010

Print booklets on Mac

One feature that is missing on Mac Snow Leopard is the ability to print a booklet from a pdf. But here is a great free application that fills that void:

http://bit.ly/2JupkE

By the way, to print even and odd pages on a Mac you need to select the "Paper Handling" option in the "Preview" dropdown.