Running AIR app from Flex Builder does nothing

April 5th, 2009

I ran into a weird problem when trying to work on someone else’s already created AIR application. I imported the project into FlexBuilder and cleaned it. When I ran, I didn’t get any compile or run-time errors – but nothing happened. The AIR window never showed up.

After much frustration, I discovered the problem was caused by having the wrong namespace defined in the application descriptor file.

The application.xml file had this as its namespace (note that ‘application’ is the name of your app, generally found at the root of your project):

< application xmlns="http://ns.adobe.com/air/application/1.0" >

I was using AIR version 1.5, so this prevented the app from running on my system. I changed it to:

< application xmlns="http://ns.adobe.com/air/application/1.5" >

Then everything ran fine.

Note that if you have experienced this (the nothing happening part), you may need to press Ctrl+Alt+Delete on Windows, and end the ADL.exe task first. It never hurts to clean the project again either.

Unknown error generating output application.xml files

April 5th, 2009

I get the following error at random times when compiling an AIR app in FlexBuilder:

Unknown error generating output application.xml files

It suggests consulting the error log, which usually mentions something about the application.xml file being read-only.

The catch is, you don’t need to set the main application.xml file to be read/write. You need to change the application.xml file within the bin-debug folder to have read/write privileges. After doing so, clean the project and try to run it again. It should be fine.

Note that the file application.xml is actually whatever your application name is, dot xml.

Running a script in MySQL

April 5th, 2009

To run a .sql script in MySQL – after logging into MySQL, enter:

source pathToScript/filename.sql

Adding a new user in MySQL

April 5th, 2009

I had a tough time getting this to work, so I’m putting it here. To add a new user to a MySQL database:

CREATE USER 'username'

then:

GRANT SELECT, INSERT
ON 'database'.*
TO 'username'
IDENTIFIED BY 'password'

This creates a user named username and gives them Select and Insert privileges to the database called database. They will need to log in with the password password.

To log in to MySQL as this user:

mysql -u username -p

This will prompt them for their password as assigned above.

AIR Chrome

April 5th, 2009

To remove the window chrome in an AIR app, there are a few steps you need to take.

1. In the application’s application.xml file, set the systemChrome tag to none.

2. Set the transparent tag to true.

3. Flex automatically starts with the tag. This is fine if you want the chrome, but if you don’t you’ll need to change this to the standard tag.

This should hide the chrome. You will need to provide functions for moving, resizing, and closing the application.

If you need to drag/move a window in AIR, stage.window.startMove() does not work. Use stage.nativeWindow.startMove() (window was replaced by nativeWindow).

To close the application, add a function to handle the close event and include this call:

stage.nativeWindow.close();

Showing hand cursor on a sprite with text in it

April 5th, 2009

In Actionscript 3, you don’t automatically get a hand cursor over a sprite/movieclip, even if it has a MouseEvent.CLICK event listener attached to it. You have to set two properties in order to see the hand cursor:

var sp:Sprite = new Sprite();
sp.buttonMode = true;
sp.useHandCursor = true;

However, this doesn’t help if you have any content within the sprite that could be clickable/selectable. To get the hand cursor when the sprite has children, you must also do:

sp.mouseChildren = false;

And depending on the events attached, you may also need:

sp.mouseEnabled = true;

This is my new blog…

March 29th, 2009

Some things in here may be useful to others, and some not. The main purpose of this is after I spend hours trying to figure out how to do something, I can put it here for quick reference next time. Otherwise, I’ll forget 5 minutes later.