📄 columnlist.mxml
字号:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
width="400" height="200"
horizontalScrollPolicy="off" verticalCenter="off">
<mx:Metadata>
[Event(name="change", type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
///////////////////////////////////////////////////////////////////////////////////
//import
import com.flexShowcase.data.Tag;
import mx.controls.*;
import mx.events.*;
import mx.collections.ArrayCollection;
////////////////////////////////////////////////////////////////
//getter/setter variables
private var _listData:ArrayCollection;
////////////////////////////////////////////////////////////////
//private variables
private var _checkboxes:Array=new Array();
///////////////////////////////////////////////////////////
//GETTER/SETTER
[Bindable]
public function set listData(val:ArrayCollection):void{
_checkboxes=new Array();
this._listData=val;
}
public function get listData():ArrayCollection{
return this._listData
}
//--------------------------------------------------------
public function get checkeditems():Array{
var r_val:Array=new Array();
for(var i:uint=0;i<_checkboxes.length;i++){
var kid:CheckBox=_checkboxes[i];
if(kid.selected){
r_val.push(kid.label);
}
}
return r_val;
}
public function set checkeditems(value:Array):void {
deselectAll();
for (var j:uint = 0; j < value.length; ++j) {
var tag:Tag = value[j] as Tag;
for(var i:uint=0;i<_checkboxes.length;i++){
var kid:CheckBox=_checkboxes[i];
if (kid.label == tag.name) {
kid.selected = true;
}
}
}
}
//----------------------------------------------------------
public function get checkedTags():Array {
var r_val:Array=new Array();
for(var i:uint=0;i<_checkboxes.length;i++){
var kid:CheckBox=_checkboxes[i];
if(kid.selected){
var tag:Tag = _listData[i] as Tag;
r_val.push(tag.id);
}
}
return r_val;
}
///////////////////////////////////////////////////////////////////////////////////
//general
public function deselectAll():void{
for(var i:uint=0;i<_checkboxes.length;i++){
var kid:CheckBox=_checkboxes[i];
kid.selected=false;
}
}
private function repeatComplete(event:FlexEvent):void {
var kids:Array=tile_list.getChildren();
for(var i:uint=0;i<kids.length;i++){
var kid:Object=kids[i];
if(kid is CheckBox){
var u_kid:CheckBox=kid as CheckBox;
_checkboxes.push(u_kid);
}
}
}
private function checkBoxClickHandler(event:MouseEvent):void {
event.stopPropagation();
var o_event:Event=new Event(Event.CHANGE);
this.dispatchEvent(o_event);
}
]]>
</mx:Script>
<mx:HBox width="100%" height="100%">
<mx:Tile id="tile_list" width="100%" height="100%" direction="vertical">
<mx:Repeater id="cb_list" dataProvider="{this.listData}" repeatEnd="repeatComplete(event)">
<mx:CheckBox label="{cb_list.currentItem.name}" click="checkBoxClickHandler(event);" styleName="columnListCheckBox" />
</mx:Repeater>
</mx:Tile>
</mx:HBox>
</mx:Canvas>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -