суббота, 23 мая 2009 г.

Links for flex diver

Some jokers who call themselves flexinmotion have released a ridiculously overpriced Flex component which “will automatically track all user navigation clicks, button click, check boxes, radio buttons and a number of other controls within your app automatically” using Google Analytics. Let me show you how to save those 149 bucks.
http://blog.iconara.net/2008/04/18/how-to-save-149/

Deploying patches in your Flex application
Every time you need to make minor changes in your production application, just put them in patches.swc and upload it to the production machine.
http://flexblog.faratasystems.com/?p=279

Manifests, Namespaces and Flex Builder
http://blog.flashgen.com/2007/07/04/manifests-namespaces-and-flex-builder-2/

SSL, crossdomains.xml
flash.system.Security.loadPolicyFile("{Url to my crossdomain.xml file on the SSL virtual root}"); With these changes in place, I’m able to easily integrate Google Accounts with my Flash app.
http://www.voiceoftech.com/swhitley/?p=117

Singletons are Pathological Liars
The problem is that the APIs are pathological liars
http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/

The following example shows how you can view a Flex application’s generated source code by adding the -keep compiler argument in Flex Builder. The generated source code will appear in a /generated/ folder within the Flex Builder project’s /src/ folder. If your MXML file was named main.mxml, the generated file could be found at /generated/main-generated.as.
http://blog.flexexamples.com/2008/08/02/viewing-a-flex-applications-generated-source-code/

Adobe Flex Component Lifecycle
http://www.slideshare.net/rjowen/adobe-flex-component-lifecycle-presentation

How are you doing global exception handling in Flex/Flash/AS3
http://dougmccune.com/blog/2009/02/10/how-are-you-doing-global-exception-handling-in-flexflashas3/

DataGrid with selection by checkboxes

The DataGrid what change selection by clicking on checkboxes and accordingly change state of checkboxes by changing DataGrid selection. In addition select all by key "a" pressed.


view source enabled

CheckBoxSelectionDataGrid
package ua.org.enginer.controls {

import flash.events.Event;
import flash.events.KeyboardEvent;

import mx.collections.ArrayCollection;
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.core.ClassFactory;
import mx.events.ListEvent;

import ua.org.enginer.controls.renderers.DataGridSelectionIndicator;
import ua.org.enginer.controls.renderers.DataGridSelectionIndicatorHeader;


/**
* [a] key for select all (like [Ctrl+a])
*
* Indicate selection by CheckBoxes
*/
public class CheckBoxSelectionDataGrid extends DataGrid {

public function CheckBoxSelectionDataGrid() {
super();
addEventListener(KeyboardEvent.KEY_DOWN, onKetDown)

function onKetDown(event:KeyboardEvent):void {
//if (event.ctrlKey && event.keyCode == 65) {
// My lovely IE do not pass [Ctrl+A]... so simply [a]
if (event.keyCode == 65) {
selectAll()
}
}
}

public function selectAll(value:Boolean=true):void {
selectedItems = value ? ArrayCollection(collection).source : []
}

// storage for seted columns
private var rawColumns:Array

override public function set columns(value:Array):void {
super.columns = value
rawColumns = value
}

private var _indicatorAlign:String = "right";

public function set indicatorAlign(value:String):void {
if (value != _indicatorAlign) {
_indicatorAlign = value;
invalidateProperties()
dispatchEvent (new Event("indicatorAlignChange"));
}
}

[Bindable(event="indicatorAlignChange")]
[Inspectable(category="General", enumeration="left,right", defaultValue="right")]
public function get indicatorAlign():String {
return _indicatorAlign;
}

private var _indicatorsColumn:DataGridColumn

public function get indicatorsColumn():DataGridColumn {
if (_indicatorsColumn) return _indicatorsColumn

var selectionIndicators:DataGridColumn = new DataGridColumn()
selectionIndicators.itemRenderer = new ClassFactory(DataGridSelectionIndicator)
selectionIndicators.headerRenderer = new ClassFactory(DataGridSelectionIndicatorHeader)
selectionIndicators.width = 20
selectionIndicators.sortable = false
selectionIndicators.resizable = false

return _indicatorsColumn = selectionIndicators
}

override protected function commitProperties():void {

// clone array
var newColumns:Array = rawColumns.concat()
indicatorAlign == "right" ? newColumns.push(indicatorsColumn) :
newColumns.unshift(indicatorsColumn)
super.columns = newColumns

super.commitProperties()
}

override public function set selectedItems(items:Array):void {
super.selectedItems = items
// for recalculation
dispatchEvent(new ListEvent(ListEvent.CHANGE))
}

override public function set selectedIndices(indices:Array):void {
super.selectedIndices = indices
dispatchEvent(new ListEvent(ListEvent.CHANGE))
}

override public function set dataProvider(value:Object):void {
super.dataProvider = value
dispatchEvent(new ListEvent(ListEvent.CHANGE))
}
}
}



DataGridSelectionIndicator
package ua.org.enginer.controls.renderers {

import flash.events.Event;

import mx.controls.CheckBox;
import mx.controls.DataGrid;
import mx.controls.listClasses.BaseListData;
import mx.events.FlexEvent;
import mx.events.ListEvent;

public class DataGridSelectionIndicator extends CheckBox {

public function DataGridSelectionIndicator() {
super();
addEventListener(Event.CHANGE, onChange)
setStyle("paddingLeft", 3)
}


private function onChange(event:Event):void {
var grid:DataGrid = DataGrid(listData.owner)
var myIndex:int = grid.itemRendererToIndex(this)

if (selected) {
if (grid.selectedIndices.indexOf(myIndex)>=0) return;
var indices:Array = grid.selectedIndices
indices.push(myIndex)
grid.selectedIndices = indices
}
else grid.selectedIndices = grid.selectedIndices.filter(function (...args):Boolean {
if (args[0] == myIndex) return false;
return true
})
}

private function onItemClick(event:Event):void {
var grid:DataGrid = DataGrid(listData.owner)
var myIndex:int = grid.itemRendererToIndex(this)
selected = grid.selectedIndices.indexOf(myIndex)>=0
}

override public function set listData(value:BaseListData):void {
super.listData = value

var grid:DataGrid = DataGrid(value.owner)

grid.addEventListener(FlexEvent.VALUE_COMMIT, onItemClick)
grid.addEventListener(ListEvent.ITEM_CLICK, onItemClick)
//grid.addEventListener(ListEvent.CHANGE, onItemClick)
selected = false
}

override public function set data(value:Object):void {
// prevent default behavior
}
}
}




DataGridSelectionIndicatorHeader
package ua.org.enginer.controls.renderers {

import flash.events.Event;

import mx.controls.CheckBox;
import mx.controls.DataGrid;
import mx.controls.listClasses.BaseListData;
import mx.events.FlexEvent;
import mx.events.ListEvent;

import ua.org.enginer.controls.CheckBoxSelectionDataGrid;

// fixme: do not change state on click
public class DataGridSelectionIndicatorHeader extends CheckBox {

private var grid:CheckBoxSelectionDataGrid

public function DataGridSelectionIndicatorHeader() {
super();
addEventListener(Event.CHANGE, onChange)
setStyle("paddingLeft", 3)
toolTip = "Отметить все"
}


private function onChange(event:Event):void {
grid.selectAll(selected)
}

override public function set listData(value:BaseListData):void {
//super.listData = value
grid = CheckBoxSelectionDataGrid(value.owner)
}

override public function set data(value:Object):void {
// prevent default behavior
}

}
}


четверг, 14 мая 2009 г.

Что изображено на логотипе?

Как вы думаете что изображено на рисунке сверху поцентру?