加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex动态生成checkbox

发布时间:2020-12-15 04:29:48 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"? mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" x="46" y="42" creationComplete="initApp()" ?? ?mx:Script ?? ??? ?![CDATA[ ?? ??? ??? ?import mx.controls.CheckBox; ?? ??? ??? ?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" x="46" y="42" creationComplete="initApp()">
?? ?<mx:Script>
?? ??? ?<![CDATA[
?? ??? ??? ?import mx.controls.CheckBox;
?? ??? ??? ?
?? ??? ??? ?private function initApp():void
?? ??? ??? ?{
?? ??? ??? ??? ?var items:Array = ["apple","boy","cat","dog","eye","fox"];
?? ??? ??? ??? ?
?? ??? ??? ??? ?for(var i:int=0;i<items.length;i++)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?var checkBox:CheckBox = new CheckBox();
?? ??? ??? ??? ??? ?checkBox.id = "checkBox" + i.toString();
?? ??? ??? ??? ??? ?checkBox.label = items[i].toString();
?? ??? ??? ??? ??? ?checkBox.setStyle("fontSize",14);
?? ??? ??? ??? ??? ?checkBox.x = 100;
?? ??? ??? ??? ??? ?checkBox.y = (i + 1) * 25;
?? ??? ??? ??? ??? ?checkBox.addEventListener(Event.CHANGE,checkBox_change);
?? ??? ??? ??? ??? ?this.addChild(checkBox);//也可是this.gridItem.addChild(checkBox)
?? ??? ??? ??? ?}? ?
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?private function checkBox_change(e:Event):void
?? ??? ??? ?{
?? ??? ??? ??? ?if(e.target.selected)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?lbItems.text = lbItems.text+e.target.label+" ";
?? ??? ??? ??? ?}
?? ??? ??? ??? ?else
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?lbItems.text = lbItems.text.replace(e.target.label,"");
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?]]>
?? ?</mx:Script>
?? ?<mx:Label id="lbItems" x="56" y="245" text="Your choice is: " width="345" fontSize="14"/>

</mx:Application>



================项目一部分

<?xml version="1.0" encoding="utf-8"?> <s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009" ?? ??? ?? xmlns:s="library://ns.adobe.com/flex/spark" ?? ??? ?? xmlns:mx="library://ns.adobe.com/flex/mx" ?? ??? ?? creationComplete="initApp(event)"? borderColor="#67c4ed" borderWeight="3" ?? ??? ?? cornerRadius="5" ?? ??? ?? width="800" height="378"> ?? ?<fx:Script> ?? ??? ?<![CDATA[ ?? ??? ??? ?import com.sybuild.platform.entity.result.ListInfoResult; ?? ??? ??? ?import com.sybuild.sdxt.cspz.dataprovider.SysParamDP; ?? ??? ??? ? ?? ??? ??? ?import mx.events.FlexEvent; ?? ??? ??? ?import mx.rpc.events.FaultEvent; ?? ??? ??? ?import mx.rpc.events.ResultEvent; ?? ??? ??? ? ?? ??? ??? ?import spark.components.CheckBox; ?? ??? ??? ? ?? ??? ??? ?private var _sysparamDp:SysParamDP = SysParamDP.getInstance(); ?? ??? ??? ? ?? ??? ??? ?protected function initApp(event:FlexEvent):void ?? ??? ??? ?{ ?? ??? ??? ??? ?getSysParamList(); ?? ??? ??? ?} ?? ??? ??? ?protected function getSysParamList():*{ ?? ??? ??? ??? ?try{ ?? ??? ??? ??? ??? ?this._sysparamDp.querySysParamList(getSysParamListSuccess,getSysParamListFalut); ?? ??? ??? ??? ?}catch(ex:Error){ ?? ??? ??? ??? ?} ?? ??? ??? ?} ?? ??? ??? ? ?? ??? ??? ?public function getSysParamListSuccess(event:ResultEvent):void{ ?? ??? ??? ??? ?this._sysparamDp.removegetSysParamListListener(getSysParamListSuccess,getSysParamListFalut); ?? ??? ??? ??? ?if (event.result == null){ ?? ??? ??? ??? ??? ?return; ?? ??? ??? ??? ?} ?? ??? ??? ??? ?if (!(event.result is ListInfoResult)){ ?? ??? ??? ??? ??? ?return; ?? ??? ??? ??? ?} ?? ??? ??? ??? ?var syslist:ListInfoResult=event.result as ListInfoResult; ?? ??? ??? ??? ?if (!syslist.success){ ?? ??? ??? ??? ??? ?return; ?? ??? ??? ??? ?} ?? ??? ??? ??? ?if (syslist.res == null || syslist.res.length == 0){ ?? ??? ??? ??? ??? ?return; ?? ??? ??? ??? ?} ?? ??? ??? ??? ?for(var i:int=0;i<syslist.res.length;i++) ?? ??? ??? ??? ?{ ?? ??? ??? ??? ??? ?var checkBox:CheckBox = new CheckBox(); ?? ??? ??? ??? ??? ?checkBox.id = "checkBox" + i.toString(); ?? ??? ??? ??? ??? ?checkBox.label = syslist.res.getItemAt(i).val; ?? ??? ??? ??? ??? ?checkBox.setStyle("fontSize",14); ?? ??? ??? ??? ??? ?checkBox.x = 100; ?? ??? ??? ??? ??? ?checkBox.y = (i + 1) * 25; ?? ??? ??? ??? ??? ?checkBox.addEventListener(Event.CHANGE,checkBox_change); ?? ??? ??? ??? ??? ?this.addChild(checkBox);//也可是this.gridItem.addChild(checkBox) ?? ??? ??? ??? ?}? ? ?? ??? ??? ?} ?? ??? ??? ? ?? ??? ??? ?public function getSysParamListFalut(event:FaultEvent):void{ ?? ??? ??? ??? ?this._sysparamDp.removegetSysParamListListener(getSysParamListSuccess,getSysParamListFalut); ?? ??? ??? ?} ?? ??? ??? ? ?? ??? ??? ?private function checkBox_change(e:Event):void ?? ??? ??? ?{ ?? ??? ??? ??? ?if(e.target.selected) ?? ??? ??? ??? ?{ ?? ??? ??? ??? ??? ?lbItems.text = lbItems.text+e.target.label+" "; ?? ??? ??? ??? ?} ?? ??? ??? ??? ?else ?? ??? ??? ??? ?{ ?? ??? ??? ??? ??? ?lbItems.text = lbItems.text.replace(e.target.label,""); ?? ??? ??? ??? ?} ?? ??? ??? ?} ?? ??? ??? ? ?? ??? ?]]> ?? ?</fx:Script> ?? ?<mx:Label id="lbItems" x="25" y="256" text="您选择了配置参数为: " width="495" fontSize="14" fontFamily="宋体"/> </s:BorderContainer>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读