20090703

Sorting an ArrayCollection



public function sortCollection(arrayCollection : ArrayCollection) : void
{
//Create the sort field
var dataSortField:SortField = new SortField();

//name of the field of the object on which you wish to sort the Collection
dataSortField.name = "name";
dataSortField.caseInsensitive = true;

/*
If you wish to perform numeric sort then set:
dataSortField.numeric = true;
*/

//create the sort object
var dataSort:Sort = new Sort();
dataSort.fields = [dataSortField];

arrayCollection.sort = dataSort;
//refresh the collection to sort
arrayCollection.refresh();

}


20090606

compilation error in Variable declaration

If you see the following exception and unable to figure out what is the reason. Don't panic. Just relax and look for a syntax error among the variable declarations in the last set of files you edited after which this error started coming.
Flex3 compiler and Flex3 Builder is unable to figure out such syntax errors:
http://bugs.adobe.com/jira/browse/SDK-15030



[mxmlc] Error: macromedia.asc.parser.MetaDataEvaluator$KeyValuePair

[mxmlc] java.lang.ClassCastException: macromedia.asc.parser.MetaDataEvaluator$KeyValuePair
[mxmlc] at macromedia.asc.parser.MetaDataEvaluator.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.SetExpressionNode.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.MetaDataEvaluator.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.MemberExpressionNode.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.MetaDataEvaluator.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.ListNode.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.MetaDataEvaluator.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.ExpressionStatementNode.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.MetaDataEvaluator.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.ClassDefinitionNode.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.MetaDataEvaluator.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.StatementListNode.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.MetaDataEvaluator.evaluate(Unknown Source)
[mxmlc] at macromedia.asc.parser.ProgramNode.evaluate(Unknown Source)
[mxmlc] at flex2.compiler.as3.Compiler.analyze3(Compiler.java:531)
[mxmlc] at flex2.compiler.mxml.InterfaceCompiler.analyze3(InterfaceCompiler.java:378)



Some examples where the above exception will be reported by mxmlc are :


public var myButton = String = null;
public var myButton : String = null; = null;


20090604

Location of Flash SharedObject (cookie)

Shared objects are stored in .sol files located in the Flash player directory of the user's profile:

* Windows Vista : C:\Users\{user-name}\AppData\Roaming\Macromedia\Flash Player\
* Windows XP : "C:/Documents and Settings/{user-name}/Application Data/Macromedia/Flash Player"
* Linux : /home/{user-name}/.macromedia/Flash_Player/
* Mac : /Users/{user-name}/Library/Preferences/Macromedia/Flash Player/

20090601

Flex4 - Gumbo beta released

Overview:

http://opensource.adobe.com/wiki/display/flexsdk/Gumbo


Download:

http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4

DataGrid - Extracting edited Value from DataGridEvent




private function saveValue(event:DataGridEvent) : void
{
if(event.reason == DataGridEventReason.CANCELLED)
return;
var newValue : String = TextInput(event.currentTarget.itemEditorInstance).text;
var prevCellValue : String = myDataGrid.selectedItem[event.dataField];

if( prevCellValue == newValue)
return;
Alert.show("New value :: "+newValue);
}

...
...

<mx:DataGrid id="myDataGrid" width="100%" dataProvider="{defCreativeVals}" editable="true" itemEditEnd="{saveValue(event)}">
<mx:columns>
<mx:DataGridColumn headerText="Column" id="colColumn" editable="false" dataField="name"/>
<mx:DataGridColumn headerText="Value" id="colValue" editable="true" dataField="value" />
</mx:columns>
</mx:DataGrid>

20090112

Location of flashlog.txt

The output of trace statements is logged to flashlog.txt in the debug version of Flash l
Following is the location of flash player log file (flashlog.txt) on various operating systems.


  • Windows Vista : C:\Users\{user-name}\AppData\Roaming\Macromedia\Flash Player\Logs
  • Windows XP : C:\Documents and Settings\{user-name}\Application Data\Macromedia\Flash Player\Logs
  • Linux : /home/{user-name}/.macromedia/Flash_Player/Logs/
  • Mac : /Users/{user-name}/Library/Preferences/Macromedia/Flash Player/Logs/