Wednesday, February 27, 2008

SQLStatement lesson

I've been working a lot with the new built-in database that comes bundled with AIR and I ran into something that gave me a bit of trouble.
It was retrieving some info from the database and reading the SQLResult using the getResult() in my retrieving method from my SQLStatement. Like usual, I was trying to read if the method was called using a trace statement and also tracing out the result using getResult(). With the trace statement, I was reading everything fine, but when I went to evaluate the SQLStatement again using getResult(), I always got NULL. How can this be? I traced out a result!? Well it turns out (if you read the help files carefully) that "When there are no more SQLResult objects left in the queue, getResult() returns null." So even tracing out getResult() removes it from the SQLStatement queue! So be warned, pass it to a variable BEFORE reading it and you'll save a lot of time troubleshooting!

Another lesson learned, but it wouldn't fun if it wasn't ;)

Tuesday, February 12, 2008

Reading a local database created with AIR

I found this neat little app that reads a SQLite database, so you can quickly and easily see whats been written to the database from your AIR file.

Hopefully, it will help you as much as it's helped me recently ;)

Friday, February 8, 2008

Posting Code on Blogger

<------ RANT Start ----->
Well I've several hours trying to find an easy way to post code on Blogger and I'm convinced it can't be done. At least not easily. I know wordpress has a easy way of doing why not Blogger? They even have a repository of code at Google CODE, so you'd think this would be an easy task.

Well if anyone knows how to do it, please let me know.
<------ RANT End----->

Wednesday, February 6, 2008

AS3 Custom Events

I've read in couple of blogs (this one recently) on the problems with passing data between Objects/Classes. I, myself, used to use Proxy as well as binding data to dynamic classes (ie-MovieClip) a LOT of the time in AS2, but now in AS3 things have changed (for the BETTER!).
In comes Custom Events. I recently used Custom Events in a project where I wrote a Class for controlling the Sound object. I found using Custom Events was MUCH easier than it's reputation is known for, and very similar in nature to Proxy. Below is a quick Sample of the SoundControlEvent.





With CustomEvents it easy to read the passed property without having to access the dispatching object. As outlined below:

var evt:SoundControlEvent = new SoundControlEvent(SoundControlEvent.SOUND_POSITION);
evt.position = _channel.position;
dispatchEvent(evt);

Hopefully Custom Events will become more popular as AS3 gets futher into the mainstream. It makes for easy to read code that extremely portable.

Monday, February 4, 2008

Communicating between AIR (swf) windows

I wanted to make a quick note on something I came across yesterday as I was working on my AIR app that uses separate NativeWindows.
Essentially what I wanted to do was call a method in another swf and pass it an argument.. a path to a song in the local file system. The way I approached this was with LocalConnection. (If there is another way to communicate between NativeWindows please let me know!) I had set up listeners in the swf for a status.level of either 'status' or 'error' so I could make sure I was actually communicating. Every time I tried to communicate between the two swf's I would get an 'error' condition. What was the problem? It seems that in AIR you must allow the local domain. As soon as I added:

_conn.allowDomain('*');
Everything worked fine.

Hopefully this will help someone searching for some answers on communicating between windows.

Sunday, February 3, 2008

Multiple Windows in AIR

I was working on my MusicPlayer app and I wanted to open my player from the playlist manager in another window. This actually isn't very hard, but if you're not careful you'll open the new window and nothing will appear! That's because after you've initialize all the NativeWindow properties you MUST set the visible property to true. If you don't, the window is created but nothing is visible on screen.

Luckily for me I was opening a swf with sound or else I wouldn't never known something fishy was happening and might've thought I was initializing it incorrectly. I could hear the music but I couldn't see anything. After reviewing some examples, I could see the error of my ways.

On a similar note, make sure you set the stage.scaleMode and stage.align properties for the new window or else you may end up with a very odd sized loaded asset.

Friday, February 1, 2008

I'm BACK!!

After a looooong break with job changes and freelance work I'm back blogging again. I'm going to try and keep my blogs now to all my experiments in AIR and Actionscript 3 and post the results whenever I can.

My first post back is about a little problem that had me pulling my hair (what I have left of it) out. What should've taken me about 10 minutes took over 3 hours! I'm hoping this may help someone else out and save them the aggrevation. It has to do with the latest AIR beta 3 update available at adobe labs.

Being the impatient person I am, I always love to play with the lastes toys, I downloaded the latest AIR beta update. The first thing you have to know is that you HAVE to update your Flash CS3 to Flash 9.0.2. That took me about two attempts to install the update to figure out (the updater just states something along the lines of "This program does not qualify for this update.".. very helpful). After that was complete the updater worked, but none of my AIR apps would compile it kept giving me the error that a class couldn't be found. That really confused me because I knew I had updated everything. I then tried the command in Flash "AIR - Create AIR file" which still produced the same error. Now I was really confused. After some searches on Adobe labs, it stated that this error will only occur on the first compile... which wasn't happening (at least for me). After tinkering around I finally noticed that on another file that did compile the following was missing from the publish settings in the Actionscript 3.0 classpaths:


$(AppConfig)/ActionScript 3.0 AIR 1.0/Classes

After I added that to my newly created app, everything compiled correctly. Now I just hope Adobe makes things a little easier when version 1 is released.