Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-08-2008, 04:38 AM   #1
chaitanya
Registered User
 
Join Date: May 2008
Posts: 35
Default textboxes in loop

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>
chaitanya is offline   Reply With Quote
Old 07-08-2008, 04:39 AM   #2
chaitanya
Registered User
 
Join Date: May 2008
Posts: 35
Default textboxes in loop

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>
chaitanya is offline   Reply With Quote
Old 07-08-2008, 03:31 PM   #3
box86rowh
FLEX AND FLASH ARE COOL
 
Join Date: Oct 2005
Posts: 794
Default

your issue lies in your for loop,
you cant access an object using strings, you can use getChildByName("t" + i).length
to get the length of the text, and getChildByName("t" + i).text to get the text.
box86rowh is offline   Reply With Quote
Old 07-09-2008, 05:38 AM   #4
chaitanya
Registered User
 
Join Date: May 2008
Posts: 35
Default

Thanks for replying, but the length and text property are not working for this getChildByName

the errors are

Access of possibly undefined property length through a reference with static type flash.displayisplayObject.

Access of possibly undefined property text through a reference with static type flash.displayisplayObject.
chaitanya is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
one template, many looks? subquark ActionScript 1.0 (and below) 1166 10-29-2013 06:18 PM
Array Problem/Instance/Copy? zoimt ActionScript 3.0 6 04-27-2008 09:01 PM
State Engine code-based Loop into time-based Loop dirge ActionScript 3.0 2 05-08-2007 07:35 PM
for loop with xml - cant understand the loop skjc ActionScript 2.0 5 01-10-2006 07:56 AM
how can i optimize this further ? if possible fantasio ActionScript 1.0 (and below) 10 07-10-2004 01:18 AM


All times are GMT. The time now is 09:09 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.