chaitanya
07-08-2008, 04:38 AM
Hi , wht i need is , on click of a button, i should get the values of the texbox if and only if, it is filled with some no, i want to keep all this in loop, can anyone suggest me...........
Here i have 4 textboxes and 4 color pickers, if i change color in colorpicker the no will be displayed in the textbox, if i click on the button, i should get the values of the filled textboxes. that should be displayed in the textarea...........
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
public var sk_list:String = "";
public function changeColor(txt:Object,color:Object):void
{
txt.text = uintToHex(color.selectedColor)
}
private function uintToHex(value:uint):String
{
var prefix:String = "000000";
var str:String = String(prefix + value.toString(16));
return "0x"+ str.substr(-6).toUpperCase()
}
private function onClick():void
{
for(var i:Number=1;i<=4;i++)
{
if(("t"+i).length !=0)
{
sk_list += ("sk_color"+i)+"="+['t'+i].text;
ta.text = sk_list;
}
}
}
]]>
</mx:Script>
<mx:TextInput x="109" y="119" width="80" id="t1"/>
<mx:TextInput x="109" y="149" width="80" id="t2"/>
<mx:TextInput x="109" y="179" width="80" id="t3"/>
<mx:TextInput x="109" y="209" width="80" id="t4"/>
<mx:ColorPicker x="209" y="119" id="cp1" change="changeColor(t1,cp1)"/>
<mx:ColorPicker x="209" y="149" id="cp2" change="changeColor(t2,cp2)"/>
<mx:ColorPicker x="209" y="179" id="cp3" change="changeColor(t3,cp3)"/>
<mx:ColorPicker x="209" y="209" id="cp4" change="changeColor(t4,cp4)"/>
<mx:Button x="357" y="94" label="Click" id="b" click="onClick()"/>
<mx:TextArea x="314" y="124" id="ta" height="107"/>
</mx:Application>
Here i have 4 textboxes and 4 color pickers, if i change color in colorpicker the no will be displayed in the textbox, if i click on the button, i should get the values of the filled textboxes. that should be displayed in the textarea...........
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
public var sk_list:String = "";
public function changeColor(txt:Object,color:Object):void
{
txt.text = uintToHex(color.selectedColor)
}
private function uintToHex(value:uint):String
{
var prefix:String = "000000";
var str:String = String(prefix + value.toString(16));
return "0x"+ str.substr(-6).toUpperCase()
}
private function onClick():void
{
for(var i:Number=1;i<=4;i++)
{
if(("t"+i).length !=0)
{
sk_list += ("sk_color"+i)+"="+['t'+i].text;
ta.text = sk_list;
}
}
}
]]>
</mx:Script>
<mx:TextInput x="109" y="119" width="80" id="t1"/>
<mx:TextInput x="109" y="149" width="80" id="t2"/>
<mx:TextInput x="109" y="179" width="80" id="t3"/>
<mx:TextInput x="109" y="209" width="80" id="t4"/>
<mx:ColorPicker x="209" y="119" id="cp1" change="changeColor(t1,cp1)"/>
<mx:ColorPicker x="209" y="149" id="cp2" change="changeColor(t2,cp2)"/>
<mx:ColorPicker x="209" y="179" id="cp3" change="changeColor(t3,cp3)"/>
<mx:ColorPicker x="209" y="209" id="cp4" change="changeColor(t4,cp4)"/>
<mx:Button x="357" y="94" label="Click" id="b" click="onClick()"/>
<mx:TextArea x="314" y="124" id="ta" height="107"/>
</mx:Application>