Important Spry/AIR Resource

I was very much into AIR in the past, but kind of fell behind this summer. I’m spending some time this month getting back into it, and I’ve run afoul of some of the big security changes that were made. One thing to note, in particular, are issues with Spry and AIR. You can find out details here:

http://labs.adobe.com/technologies/spry/air.html

The page tells you to go look at the docs, which help a bit, but here are some concrete examples. First, I had a simple drop down bound to a dataset. I made it so that when you selected an item, it set the current row. This then fired off another dataset. Anyway, the old code was:

<select id="librarydd" name="library" onChange="libs.setCurrentRow(this.selectedIndex);">

If you read the Spry/AIR link above, you will see that this no longer works. Instead you need to use a region observer. A region observer watches changes to a div/span that is generated by Spry. So I begun by writing code to run after the drop down region was generated.

myObserver = new Object; myObserver.onPostUpdate = function(notifier, data) { Spry.Utils.addEventListener("librarydd", "change", libHandler, false); }; Spry.Data.Region.addObserver("libregion", myObserver);

This code basically says: When you are doing drawing the region, run my onPostUpdate function. That code then adds an event listener for the change event. It’s bound to the library drop down and runs a function named libHandler. Finally, this function is:

function libHandler() { libs.setCurrentRow(this.selectedIndex); }

So - a lot of work, but after banging my head against the wall for a few hours, it at least makes sense to me now. I hope to have my new sample code released tomorrow.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate looking for his next gig. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments