After more work than I expected, I’ve updated my Weewar status notifier to work with the Adobe Air Beta 2 SDK.
There were two tricky parts to the update. The first, separating the AJAX/UI logic out into a separate sandbox. The second challenge was getting rid of the pesky scrollbars AIR seemed to insist upon putting on my window.
Separating the logic
Due to the new sandbox security policy, you can no longer use “eval()” code in the main code. This is to protect it from access to files and assorted operating system resources. Instead, you have to split that code out into a remote sandbox and talk through a bridge. It was not too hard to follow the Security FAQ about how to do that. Still, it took way to long to figure out the gotchas. There were two.
First, magic variables. In your sandbox, you’ll have the magic variable “parentSandboxBridge” which will have all your exported functionality from the main code. Awkward, but it works.
Second — and this cost me some time to debug — you don’t have that variable for a while. So if you are trying to execute some code on load, you need to put in a delay loop to wait for it to appear. This worked for me:
weewar.init = function () {
if (typeof(parentSandboxBridge) == 'undefined') {
setTimeout('weewar.init()', 1000);
}
// initialization code requiring the active bridge follows
// ...
}
Pesky Scrollbars
Even though I had system chrome turned off, AIR insisted upon putting in (very ugly) scrollbars whenever I would specify a height or a width for the HTML content. Argh! Through trial, error, and shrewd guessing, I finally found the key. Simply do your body like so "<body style=’overflow: hidden;’>"
















0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment