<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” height=”388″ creationComplete=”initApp()”>
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.events.ItemClickEvent;
import flash.events.Event;
import mx.controls.Alert;
private var s:String="";
private var u:String="";
private var c:String="";
private function initApp():void{
b.addEventListener(MouseEvent.CLICK,sub);
}
public function le(event:Event):void
{
if(event.currentTarget.toString()=="newpro0.li")
{
c=li.selectedItem.toString();
}
if(event.currentTarget.toString()=="newpro0.co")
{
u=co.selectedItem.toString();
}
}
public function reve(event:ItemClickEvent):void
{
s=SEX.selectedValue.toString();
}
public function sub(e:MouseEvent):void
{
tx.text="name:"+nam.text+"\nsex:"+s+"\nU.G:"+u+"\nspecialization:"+c;
lb3;
}
]]>
</mx:Script>
<mx:Label x=”70″ y=”35″ text=”NAME” width=”43″/>
<mx:TextInput id=”nam” x=”143″ y=”33″/>
<mx:Label id=”se” x=”70″ y=”95″ text=”SEX” width=”43″/>
<mx:RadioButtonGroup id=”SEX” itemClick=”reve(event);”/>
<mx:RadioButton x=”143″ y=”86″ value=”male” label=”MALE” groupName=”SEX”/>
<mx:RadioButton x=”143″ y=”112″ value=”female” label=”FEMALE” groupName=”SEX”/>
<mx:ComboBox change=”le(event)” id=”co” x=”143″ y=”153″>
<mx:ArrayCollection>
<mx:String>BE</mx:String>
<mx:String>BSC</mx:String>
<mx:String>BCOM</mx:String>
</mx:ArrayCollection>
</mx:ComboBox>
<mx:Label x=”70″ y=”155″ text=”U.G”/>
<mx:List change=”le(event)” id=”li” x=”143″ y=”194″ width=”118″ height=”71″>
<mx:dataProvider>
<mx:String >cse</mx:String >
<mx:String>it</mx:String>
<mx:String>ece</mx:String>
</mx:dataProvider>
</mx:List>
<mx:Label x=”24″ y=”213″ text=”SPECIALIZATION”/>
<mx:Button id=”b” x=”345″ y=”243″ label=”submit” />
<mx:TextArea id=”tx” x=”143″ y=”302″ height=”76″/>
<mx:Label id=”lb3″ x=”47″ y=”324″ text=”Label”/>
</mx:Application>
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” height=”388″ creationComplete=”initApp()”>
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.events.ItemClickEvent;
import flash.events.Event;
import mx.controls.Alert;
private var s:String="";
private var u:String="";
private var c:String="";
private function initApp():void{
b.addEventListener(MouseEvent.CLICK,sub);
}
public function le(event:Event):void
{
if(event.currentTarget.toString()=="newpro0.li")
{
c=li.selectedItem.toString();
}
if(event.currentTarget.toString()=="newpro0.co")
{
u=co.selectedItem.toString();
}
}
public function reve(event:ItemClickEvent):void
{
s=SEX.selectedValue.toString();
}
public function sub(e:MouseEvent):void
{
tx.text="name:"+nam.text+"\nsex:"+s+"\nU.G:"+u+"\nspecialization:"+c;
lb3;
}
]]>
</mx:Script>
<mx:Label x=”70″ y=”35″ text=”NAME” width=”43″/>
<mx:TextInput id=”nam” x=”143″ y=”33″/>
<mx:Label id=”se” x=”70″ y=”95″ text=”SEX” width=”43″/>
<mx:RadioButtonGroup id=”SEX” itemClick=”reve(event);”/>
<mx:RadioButton x=”143″ y=”86″ value=”male” label=”MALE” groupName=”SEX”/>
<mx:RadioButton x=”143″ y=”112″ value=”female” label=”FEMALE” groupName=”SEX”/>
<mx:ComboBox change=”le(event)” id=”co” x=”143″ y=”153″>
<mx:ArrayCollection>
<mx:String>BE</mx:String>
<mx:String>BSC</mx:String>
<mx:String>BCOM</mx:String>
</mx:ArrayCollection>
</mx:ComboBox>
<mx:Label x=”70″ y=”155″ text=”U.G”/>
<mx:List change=”le(event)” id=”li” x=”143″ y=”194″ width=”118″ height=”71″>
<mx:dataProvider>
<mx:String >cse</mx:String >
<mx:String>it</mx:String>
<mx:String>ece</mx:String>
</mx:dataProvider>
</mx:List>
<mx:Label x=”24″ y=”213″ text=”SPECIALIZATION”/>
<mx:Button id=”b” x=”345″ y=”243″ label=”submit” />
<mx:TextArea id=”tx” x=”143″ y=”302″ height=”76″/>
<mx:Label id=”lb3″ x=”47″ y=”324″ text=”Label”/>
</mx:Application>
In this code u can see that both the combo box and the list are using the change event dispatcher which call the function le()
In the le() function see the line
if(event.currentTarget.toString()==”newpro0.co”)
which will check at which object the event was targetted
here newppro0 is thew name of the project, that is the class and co is the combobox object so the code inside the if will be executed if the event was targetted at the combo box else it will check with the list box whether it was the target and execute the prescribed code.thus handling two controls events in a single function
Great idea, but will this work over the long run?
Comment by Make Money — August 7, 2009 @ 2:04 pm |
thanks for ur comment
i think this idea will work
plz change ur name becoz im not able to find ur comment
as it was sent to the spam .
Comment by selvakumar p — August 10, 2009 @ 5:37 am |