Tuesday, October 28, 2008

"Unknown error generating output application.xml files"

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.

Monday, August 4, 2008

Running a script in MySQL

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

source pathToScript/filename.sql

Tuesday, July 15, 2008

Adding New User to MySQL

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.

Adding Database via ColdFusion to Flex project

Steps to add a new database to a Flex project:

1. Open the ColdFusion Admin page. Its probably here: http://localhost/CFIDE/administrator/index.cfm

2. Click Data Sources on left side.

3. In the Data Source Name field, give the new db a name. You will refer to this name in the ColdFusion Component datasource property.

4. In the settings, the Database field is the name of your database in MySQL. The username and password is the user/pw associated with that database in MySQL. If you need to add a new user in MySQL, follow the steps in the post called "Adding a New User in MySQL."

5. In Flex, you will refer to the ColdFusion component like this:

< id="requestName" destination="ColdFusion" source="componentFolder.cfcName">>
< /mx:RemoteObject >


For example, in the Inetpub\wwwroot folder I have a folder called components. Inside of here, I have a ColdFusion component called users.cfc. The users.cfc component contains a method called getUsers(). The RemoteObject call for this would be:

< id="userRequest" destination="ColdFusion" source="components.users">
< name="getUsers" result="returnHandler(event)">
< /mx:RemoteObject >



To initiate a call to this RO use: userRequest.getUsers();

The event handler for the results would be something like:

private function returnHandler(e:ResultEvent):void
{
var ac:ArrayCollection = new ArrayCollection();
ac = e.result as ArrayCollection;
}

And finally the getUsers() method in the CFC would look like this:

< name="getUsers" returntype="query">
< name="allUsers" datasource="dataSourceName">
SELECT * FROM users
< /cfquery >
<>
< /cffunction >



If anyone else is reading this, please note this is a very basic example and I'm only putting it here in case I forget how to do this in the future. I can't guarantee it is correct. :-)


Also note, the formatting keeps getting really messed up with the <<>> and some CF function names are being stripped, so hopefully its all clear.

Tuesday, May 27, 2008

Visible=false in Flex

In Flex you can hide a component using visible=false. This still includes it when calculating layout, so you will end up with a blank space the size of your component. To prevent this, use includeInLayout=false AND visible=false.

Wednesday, April 30, 2008

A few notes on AIR

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. Its 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();

Wednesday, April 23, 2008

Showing the hand cursor on a Sprite with Text in it

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;