Skip to content

Instantly share code, notes, and snippets.

@liekkas
Created May 15, 2012 15:17
Show Gist options
  • Save liekkas/2702572 to your computer and use it in GitHub Desktop.
Save liekkas/2702572 to your computer and use it in GitHub Desktop.
FLEX:Matrix Component Test
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
xmlns:local="*" horizontalAlign="center" >
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function matrix21_creationCompleteHandler(event:FlexEvent):void
{
mt.dataXML = xml;
}
protected function btn_clickHandler(event:MouseEvent):void
{
var btn:Button = event.target as Button;
var obj:Object = new Object();
switch(btn)
{
case btn1:
obj['id'] = "125";
obj['pid'] = "1";
obj['pid2'] = "12";
obj['severity'] = "1";
break;
case btn2:
obj['id'] = "111";
obj['pid'] = "1";
obj['pid2'] = "11";
obj['severity'] = "2";
break;
case btn3:
obj['id'] = "226";
obj['pid'] = "2";
obj['pid2'] = "22";
obj['severity'] = "3";
break;
case btn4:
obj['id'] = "221";
obj['pid'] = "2";
obj['pid2'] = "22";
obj['severity'] = "4";
break;
case btn5:
obj['id'] = "321";
obj['pid'] = "3";
obj['pid2'] = "32";
obj['severity'] = "0";
break;
}
mt.update(obj);
}
private var flag:Boolean;
protected function more_clickHandler(event:MouseEvent):void
{
flag = !flag
mt.more(flag);
}
private var count:int;
protected function btn6_clickHandler(event:MouseEvent):void
{
var obj:Object = new Object();
obj['id'] = (115 + count) + "";
obj['name'] = "俺是新来滴"+count;
obj['pid'] = "1";
obj['pid2'] = "11";
obj['severity'] = Math.round(Math.random()*4) + "";
count ++;
mt.addItem(obj);
}
protected function btn7_clickHandler(event:MouseEvent):void
{
var obj:Object = new Object();
obj['id'] = (114 + count) + "";
obj['pid'] = "1";
obj['pid2'] = "11";
count --;
mt.delItem(obj);
}
]]>
</mx:Script>
<mx:XML id="xml" source="matrix.xml" format="e4x"/>
<mx:Panel width="600" height="450"
paddingBottom="2" paddingLeft="2" paddingRight="2" paddingTop="2">
<local:Matrix2 id="mt" allowEmptyRow="true"
creationComplete="matrix21_creationCompleteHandler(event)"/>
</mx:Panel>
<mx:HBox>
<mx:Button id="btn1" color="red" label="模拟一条一级告警" click="btn_clickHandler(event)"/>
<mx:Button id="btn2" color="0xff9900" label="模拟一条二级告警" click="btn_clickHandler(event)"/>
<mx:Button id="btn3" color="yellow" label="模拟一条三级告警" click="btn_clickHandler(event)"/>
<mx:Button id="btn4" color="blue" label="模拟一条四级告警" click="btn_clickHandler(event)"/>
<mx:Button id="btn5" color="green" label="模拟一条清除告警" click="btn_clickHandler(event)"/>
</mx:HBox>
<mx:HBox>
<mx:Button id="btn6" label="添加一条数据" click="btn6_clickHandler(event)"/>
<mx:Button id="btn7" label="删除一条数据" click="btn7_clickHandler(event)"/>
</mx:HBox>
<mx:Button id="more" label="更多" click="more_clickHandler(event)"/>
</mx:Application>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment