[flexcoders] Finding all TextInputs in a Panel

2007-04-24 Thread Shidan
I would like to find all the TextInputs in a Panel but when I do a for
in loop over the Panel I get nothing.

for (var 0:Object in panel){
Alert.show(o.toString());
}

Can someone give me a pointer.

Thanks,
Shidan


Re: [flexcoders] Finding all TextInputs in a Panel

2007-04-24 Thread Daniel Freiman

for...in iterates over properties.  Unless you've subclassed the panel and
gave each TextInput child its own variable, then this won't give you a
Container's children.  What you want is to iterate over the children:

for (var i:int = 0; i  panel.getChildren().length; i++) {
  var child:DisplayObject = panel.getChildAt(i);
  if (child is TextInput) {
 // do something useful
  }
}

This will only work if the TextInputs are direct children of the panel.
Otherwise things will get a bit more tricky.

- Dan Freiman
nondocs http://nondocs.blogspot.com

On 4/24/07, Shidan [EMAIL PROTECTED] wrote:


  I would like to find all the TextInputs in a Panel but when I do a for
in loop over the Panel I get nothing.

for (var 0:Object in panel){
Alert.show(o.toString());
}

Can someone give me a pointer.

Thanks,
Shidan
 



RE: [flexcoders] Finding all TextInputs in a Panel

2007-04-24 Thread Andrew Trice
Or you could use a for-each loop to loop over the children:

 

for each ( var child : * in panel.getChildren() )

{

if ( child is TextInput )

{

//do something

}

}

 

-Andy

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Daniel Freiman
Sent: Tuesday, April 24, 2007 3:16 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Finding all TextInputs in a Panel

 

for...in iterates over properties.  Unless you've subclassed the panel
and gave each TextInput child its own variable, then this won't give you
a Container's children.  What you want is to iterate over the children: 

for (var i:int = 0; i  panel.getChildren().length; i++) {
   var child:DisplayObject = panel.getChildAt(i);
   if (child is TextInput) {
  // do something useful
   }
}

This will only work if the TextInputs are direct children of the panel.
Otherwise things will get a bit more tricky. 

- Dan Freiman
nondocs http://nondocs.blogspot.com 

On 4/24/07, Shidan [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]   wrote:

I would like to find all the TextInputs in a Panel but when I do a for
in loop over the Panel I get nothing.

for (var 0:Object in panel){
Alert.show(o.toString());
}

Can someone give me a pointer.

Thanks,
Shidan