flex4 的comboBox的简单问题:选择后,下面的label标签的text 值随之改变为设定的值
页面运行刚出来的时候是comboBox里面的值是Chinese嘛,没什么说的,但是当下拉选者Math时,下面有一个label标签里面的text值,在页面上也随之改变。如f...
页面运行刚出来的时候是comboBox里面的值是Chinese嘛,没什么说的,但是当下拉选者Math时,下面有一个label标签里面的text 值,在页面上也随之改变。如first 变为设定的值aaa,first2变为bbb。。。。下面注意是S开头的标签 flex4的
这个是在<fx:Script> 里面的
protected function combobox1_changeHandler(event:ListEvent):void
{
//应该就是这句代码有问题,,大虾们改下啊。。
var cb:spark.components.ComboBox = event.target as park.components.ComboBox;
if(cb.selectedItem == "Chinese"){
this.ac.text = "aaa";
this.ac2.text = "bbb";
}
</fx:Script>
<s:ComboBox change="combobox1_changeHandler(event)">
<s:dataProvider>
<fx:String>Chinese</fx:String>
<fx:String>Math</fx:String>
</>
<s:Label width="100" text="first" id="ac"/>
<s:Label width="100" text="first2" id="ac2"/> 展开
这个是在<fx:Script> 里面的
protected function combobox1_changeHandler(event:ListEvent):void
{
//应该就是这句代码有问题,,大虾们改下啊。。
var cb:spark.components.ComboBox = event.target as park.components.ComboBox;
if(cb.selectedItem == "Chinese"){
this.ac.text = "aaa";
this.ac2.text = "bbb";
}
</fx:Script>
<s:ComboBox change="combobox1_changeHandler(event)">
<s:dataProvider>
<fx:String>Chinese</fx:String>
<fx:String>Math</fx:String>
</>
<s:Label width="100" text="first" id="ac"/>
<s:Label width="100" text="first2" id="ac2"/> 展开
2个回答
展开全部
获取combobox的change事件,事件类型是IndexChangeEvent,然后再事件方法中根据combobox选择的条目信息判断label的文本变化就可以了,这个问题查flex api是可以解决的
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import spark.events.IndexChangeEvent;
[Bindable]
public var cards:ArrayCollection = new ArrayCollection(
[ {label:"中文", data:1},
{label:"English", data:2} ]);
protected function combobox2_changeHandler(event:IndexChangeEvent):void
{
//中文
if(cb.selectedItem.data == 1)
{
ac.text = "中文";
}
//English
else
{
ac.text = "English";
}
}
]]>
</fx:Script>
<s:VGroup>
<s:ComboBox id="cb" change="combobox2_changeHandler(event)" dataProvider="{cards}"/>
<s:Label width="100" text="TEXT。。。" id="ac"/>
</s:VGroup>
</s:Application>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import spark.events.IndexChangeEvent;
[Bindable]
public var cards:ArrayCollection = new ArrayCollection(
[ {label:"中文", data:1},
{label:"English", data:2} ]);
protected function combobox2_changeHandler(event:IndexChangeEvent):void
{
//中文
if(cb.selectedItem.data == 1)
{
ac.text = "中文";
}
//English
else
{
ac.text = "English";
}
}
]]>
</fx:Script>
<s:VGroup>
<s:ComboBox id="cb" change="combobox2_changeHandler(event)" dataProvider="{cards}"/>
<s:Label width="100" text="TEXT。。。" id="ac"/>
</s:VGroup>
</s:Application>
展开全部
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
protected function combobox1_changeHandler(event:Event):void
{
//应该就是这句代码有问题,,大虾们改下啊。。
if(cb.selectedLabel == "Chinese"){
this.ac.text = "aaa";
this.ac2.text = "bbb";
}
}
]]>
</fx:Script>
<fx:Declarations>
<fx:Array id="queryField">
<fx:Object headerText="Chinese"/>
<fx:Object headerText="Math"/>
</fx:Array>
<s:ArrayList id="queryField1">
<fx:Object headerText="Chinese"/>
<fx:Object headerText="Math"/>
</s:ArrayList>
</fx:Declarations>
<!--用ComboBox的话就的使用flex3 mx:ComboBox 在flex4中用s:DropDownList-->
<mx:ComboBox id="cb" dataProvider="{queryField}"
labelField="headerText" selectedIndex="1"
change="combobox1_changeHandler(event)"/>
<s:DropDownList dataProvider="{queryField1}"
labelField="headerText" selectedIndex="1"/>
<s:Label width="100" text="first" id="ac"/>
<s:Label width="100" text="first2" id="ac2"/>
</s:Application>
给分吧。挣点分不容易
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
protected function combobox1_changeHandler(event:Event):void
{
//应该就是这句代码有问题,,大虾们改下啊。。
if(cb.selectedLabel == "Chinese"){
this.ac.text = "aaa";
this.ac2.text = "bbb";
}
}
]]>
</fx:Script>
<fx:Declarations>
<fx:Array id="queryField">
<fx:Object headerText="Chinese"/>
<fx:Object headerText="Math"/>
</fx:Array>
<s:ArrayList id="queryField1">
<fx:Object headerText="Chinese"/>
<fx:Object headerText="Math"/>
</s:ArrayList>
</fx:Declarations>
<!--用ComboBox的话就的使用flex3 mx:ComboBox 在flex4中用s:DropDownList-->
<mx:ComboBox id="cb" dataProvider="{queryField}"
labelField="headerText" selectedIndex="1"
change="combobox1_changeHandler(event)"/>
<s:DropDownList dataProvider="{queryField1}"
labelField="headerText" selectedIndex="1"/>
<s:Label width="100" text="first" id="ac"/>
<s:Label width="100" text="first2" id="ac2"/>
</s:Application>
给分吧。挣点分不容易
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询