Archive for December, 2004

How big can your Flash be? See this TechNote…

I just noticed a great TechNote about how big your Flash SWF files can be.

Flash TechNote: How big can a Flash movie be?

The TechNote reviews how big your files can be, how much memory they should use, a bit about math, and so forth. It’s certainly worth a read, particularly if you live on the wild side and ever approach these (logical) limitations.

Happy holidays game…

Check out the holiday card game:

http://www.macromedia.com/macromedia/holiday2004/
(My results are more than a tad lacklustre…)

Sorting and the DataGrid component

Another Tuesday LiveDocs day! The following example continues the theme of DataGrids and sorting.

The following example sorts columns either numerically or alphabetically. By default columns are sorted alphanumerically, so if you had a DataGrid with “1, 213, 11, 7″ it would sort as “1,11,213,7”. By writing a custom sorting function that uses Array.sortOn, you can sort the dataProvider yourself using a numeric or text sort (even sort text as case insensitive).

1. Make sure you have DataGrid in Library
2. Add following ActionScript to frame 1 of the Timeline:

import mx.controls.gridclasses.DataGridColumn;
var my_dp:Array = new Array({name:’Grissom, M.’, avg:0.279}, {name:’Bonds, B.’, avg:0.362}, {name:’Cruz, D.’, avg:0.292}, {name:’Snow, J.’, avg:0.327});
var dg = this.createClassObject(mx.controls.DataGrid, “my_dg”, 999, {dataProvider:my_dp});
dg.setSize(240, 180);
var name_dgc:DataGridColumn = new DataGridColumn(“name”);
name_dgc.headerText = “Name:”;
name_dgc.width = 160;
dg.addColumn(name_dgc);
var avg_dgc:DataGridColumn = new DataGridColumn(“avg”);
avg_dgc.headerText = “Avg:”;
avg_dgc.width = 60;
dg.addColumn(avg_dgc);
//
var myListener:Object = new Object();
myListener.headerRelease = function(evt:Object) {
var sortOrder:String = evt.target.sortDirection;
var sortColumn:String = evt.target.columnNames[evt.columnIndex];
switch (sortColumn) {
case ‘name’ :
sortArray(my_dp, sortColumn, “TEXTNOCASE”, sortOrder);
break;
case ‘avg’ :
sortArray(my_dp, sortColumn, “NUMERIC”, sortOrder);
break;
}
};
my_dg.addEventListener(“headerRelease”, myListener);
//
function sortArray(my_array:Array, sortColumn:String, sortType:String, sortOrder:String) {
var sortOptions:Number = 0;
switch (sortType.toUpperCase()) {
case ‘NUMERIC’ :
sortOptions |= Array.NUMERIC;
break;
case ‘TEXTNOCASE’ :
sortOptions |= Array.CASEINSENSITIVE;
break;
}
if (sortOrder.toUpperCase() == ‘DESC’) {
sortOptions |= Array.DESCENDING;
}
my_array.sortOn(sortColumn, sortOptions);
}

3. Format the code (press the Auto Format button).
4. Test.

DataGrid.headerRelease example

Today is Tuesday LiveDocs day. Sometimes questions are posted in LiveDocs. Although please note that LiveDocs is not the place for questions about how to do things in Flash: the proper place is in the Macromedia forums. But at times, there are sections of the docs that could use some fleshing out, perhaps an additional example is necessary. So, this blog from time to time will “document” some areas where an extra example might be helpful.

First one up to bat is DataGrid.headerRelease. This example shows you how to change the direction of the DataGrid by clicking the column.

1. Drag a DataGrid onto the Stage.
2. In the property inspector, add the instance name my_dg.
3. Add the following ActionScript to frame 1 of the Timeline:

var my_dg:mx.controls.DataGrid;
my_dg.setSize(150, 100);
my_dg.spaceColumnsEqually();
var myListener:Object = new Object();
myListener.headerRelease = function(evt:Object) {
trace(“column “+evt.columnIndex+” header was pressed”);
trace(“\t current sort order is: “+evt.target.sortDirection);
trace(“”);
};
my_dg.addEventListener(“headerRelease”, myListener);
//
my_dg.addColumn(“a”);
my_dg.addColumn(“b”);
my_dg.addItem({a:’one’, b:1});
my_dg.addItem({a:’two’, b:2});

By accessing the sortDirection property, you can then tell the sort order is ascending or descending. The sortDirection is actually a string, so it traces as either ASC or DESC.

Macromedia Knowledge Base – it’s live

Although it has been mentioned on a few other Macromedia blogs and other sites as well, it is worth mentioning here that Macromedia has released their new “Knowledge Base”. What is the Knowledge Base, you ask? Well, the FAQ says the following:

What is the Macromedia Knowledge Base?
The Macromedia Knowledge Base is a self-service customer information guided search tool that allows customers to access information quickly and efficiently from macromedia.com for precise Macromedia technical information, Macromedia Developer Center articles, and Macromedia customer service notes on policies and procedures. Each search that a user performs automatically provides structured feedback to Macromedia about the technical quality of the Knowledge Base. This allows us to contribute new technical information continually to make the Knowledge Base more effective.

Go Search the Knowledge base:
Knowledge Base search

Find out more info:
http://www.macromedia.com/support/knowledgebase/

Macromedia also offers a useful Captivate (formerly RoboDemo) movie which does a great job of walking you through the new Knowledge Base.

If you have feedback regarding this new search tool, please send it using the Knowledge Base feedback form.

http://www.macromedia.com/bin/kb_feedback.cgi