Wednesday, February 16, 2005

Currency format in Flash MX 2004 DataGrid Component

The datagrid component is great. Without any programming, you can load up some data, sort it, format it and display it in your flash movie. What if you want to format the data but the built in formatting options are not good enough? I have the answer. Using the Custom Formatter feature of the datagrid component inspector, you can specify a flash AS class file to do the formatting for you. Here is how it is done using the XML component, the DataSet component and the DataGrid component.

1: Download the following .zip file and unpack it. Currency_Example.zip

2: Open the file currency_example.fla in Flash MX 2004.

3: Test the file and take a note of how the column Price and Total looks with no formatting. Sucks right?



4: You need to import your custom class so flash can see it. You can do it two ways, using action script and the import method, or using the UI. We will use the UI method. Use the Create New Symbol menu option or press CTL+F8 key combo. Type Currency in the name, click on the Export for Action Script check-box, and in the AS 2.0 field, type Currency. Case is important.

5: Go back to the main stage and click on the DataSet icon. The dataset instance is called myDataSet.

6: Open the component inspector and click on the Schema tab.

7: Locate the Price schema item and then in the properties panel, look for the formatter property. It should be blank.

8: From the drop down list for the formatter property, select the Custom option. The property below that, formatter options will now change to {}.

9: Select the formatter options drop down, and a window will pop up. Type Currency in the window and close it.

10: Test your movie again and view the Price column. Nicely formatted Currency is displayed!



Good Luck. If you just want to see finished results, open the currency_example2.fla file and test it.

Monday, February 14, 2005

Welcome to my blog.

Greetings, fellow Internetters!

I hope to find some time to post my experiences with programming for the web. Many tasks in Flash an other languages are not well documented, and I have had to spend many hours researching solutions to what I believe are common programming problems. Hopefully, I can help you reduce your search time.