[flexcoders] Re: Loop through all visual components

2008-08-13 Thread itdanny2002

Still not success. I gave an example.

My user enter something e.g. login name and 
then program display the full name.

private function DoChecking(S:String):String {
 ...
if (TryOnce) then { 
  return Already Tried;
}
else {
  return First Time;
}
}

 mx:Label id=ShowName text={DoChecking(login)}/mx:Label

First time is ok but when another button is clicked and change
the variable TryOnce. The label 'ShowName' cannot be refreshed
eventhough I use ShowName.validatedisplaylist(). I also tried
validatenow()but not successAny help ?


--- In flexcoders@yahoogroups.com, Laurent Cozic [EMAIL PROTECTED] 
wrote:

 Somebody ask a similar question on this list recently. You can loop 
through all the components in your app by using the numChildren 
property and getChildAt method:
 
 function checkAllButtons(container) {
 
 ?for (var i = 0; i  container.numChildren; i++) {
 ??var c = container.getChildAt(i);
 ??if (c is Container) {
 ???checkAllButtons(c);
 ??} else {
 ???if (c is Button) {
 // Do your changes here
 ???}
 ??}
 ? 
 }
 
 
 Then start the process by passing the application as a parameter:
 
 checkAllButtons(Application.application);
 
 
 
 
 --
 Laurent Cozic
 
 Flash, Flex and Web Application development
 http://pogopixels.com
 
 --- On Tue, 8/12/08, itdanny2002 [EMAIL PROTECTED] wrote:
 From: itdanny2002 [EMAIL PROTECTED]
 Subject: [flexcoders] Loop through all visual components
 To: flexcoders@yahoogroups.com
 Date: Tuesday, August 12, 2008, 9:19 AM
 
 
 
 
 
 
 
 
 
 
 
 I have created a custom button and used it
 
 throughoutly in my FLEX application. How 
 
 can I change it dynamically by looping through 
 
 all components ? Is there any like children
 
 stuff and then use ValidateDisplayLis t to 
 
 make it refresh ? Actually, it likes changing
 
 the skin dynamically. But I need to check the 
 
 content of button before modification. 
 
 
 
 Having example is great. Thanks in advance.





Re: [flexcoders] Re: Loop through all visual components

2008-08-13 Thread Laurent Cozic
Not sure but I think you need to make your login variable (whather that is) 
bindable, so that, when it changes, the showName label is notified:


[Bindable]
private var login:String; // just guessing the declaration. The important part 
is the [Bindable] tag



--
Laurent Cozic

Flash, Flex and Web Application development
http://pogopixels.com

--- On Wed, 8/13/08, itdanny2002 [EMAIL PROTECTED] wrote:
From: itdanny2002 [EMAIL PROTECTED]
Subject: [flexcoders] Re: Loop through all visual components
To: flexcoders@yahoogroups.com
Date: Wednesday, August 13, 2008, 10:58 AM













Still not success. I gave an example.



My user enter something e.g. login name and 

then program display the full name.



private function DoChecking(S: String):String {

 ...

if (TryOnce) then { 

  return Already Tried;

}

else {

  return First Time;

}

}



mx:Label id=ShowName text={DoChecking( login)} /mx:Label



First time is ok but when another button is clicked and change

the variable TryOnce. The label 'ShowName' cannot be refreshed

eventhough I use ShowName.validatedi splaylist( ). I also tried

validatenow( )but not successAny help ?



--- In [EMAIL PROTECTED] ups.com, Laurent Cozic pogopixels@ ... 

wrote:



 Somebody ask a similar question on this list recently. You can loop 

through all the components in your app by using the numChildren 

property and getChildAt method:

 

 function checkAllButtons( container) {

 

 ?for (var i = 0; i  container.numChildr en; i++) {

 ??var c = container.getChildA t(i);

 ??if (c is Container) {

 ???checkAllButtons( c);

 ??} else {

 ???if (c is Button) {

 // Do your changes here

 ???}

 ??}

 ? 

 }

 

 

 Then start the process by passing the application as a parameter:

 

 checkAllButtons( Application. application) ;

 

 

 

 

 --

 Laurent Cozic

 

 Flash, Flex and Web Application development

 http://pogopixels. com

 

 --- On Tue, 8/12/08, itdanny2002 Chow.Danny@ ... wrote:

 From: itdanny2002 Chow.Danny@ ...

 Subject: [flexcoders] Loop through all visual components

 To: [EMAIL PROTECTED] ups.com

 Date: Tuesday, August 12, 2008, 9:19 AM

 

 

 

 

 

 

 

 

 

 

 

 I have created a custom button and used it

 

 throughoutly in my FLEX application. How 

 

 can I change it dynamically by looping through 

 

 all components ? Is there any like children

 

 stuff and then use ValidateDisplayLis t to 

 

 make it refresh ? Actually, it likes changing

 

 the skin dynamically. But I need to check the 

 

 content of button before modification. 

 

 

 

 Having example is great. Thanks in advance.






  




 

















  

[flexcoders] Re: Loop through all visual components

2008-08-13 Thread itdanny2002

Thank you. Through your lens, I did it by :-

1. Make a custom component with custom properties
2. Make that properties be [Bindable]
3. Write a private function to change what I need 
while the cusom properties change.

Then, no need to loop through all component, and 
no need to use function like validatenow(), 
invalidatedisplaylist() 

Thank you !