ajwei810192
04-29-2009, 09:18 PM
Hi,
I have a code snippet here that I have in my application that I am trying to check to see if the clear button exists on the stage? (I think this is the term to use)
[Bindable]private var clear:Button;
private function clear_filter(event:FlexEvent):void{
box3.removeChild(clear);
}
private function clear_create():void{
if (clear) {
Alert.show("The button exist!");
}
else{
clear = new Button();
clear.label = "Clear Filter";
clear.addEventListener(FlexEvent.BUTTON_DOWN,clear _filter);
clear.y= 200;
box3.addChild(clear);
}
}
However, whenever I click on the button that activates the clear_filter function, the clear button disappears from the stage from the stage. I thought that this means that then when I call the clear_create() again with another button from the app, it would give me the clear button back. Instead, I get the Alert.show message pop up from what I have in the code where it should only appear if the clear button is on the stage.
What have I done wrong here?
Is this how I should check if an element exist on the stage?
Thanks for your help.
I have a code snippet here that I have in my application that I am trying to check to see if the clear button exists on the stage? (I think this is the term to use)
[Bindable]private var clear:Button;
private function clear_filter(event:FlexEvent):void{
box3.removeChild(clear);
}
private function clear_create():void{
if (clear) {
Alert.show("The button exist!");
}
else{
clear = new Button();
clear.label = "Clear Filter";
clear.addEventListener(FlexEvent.BUTTON_DOWN,clear _filter);
clear.y= 200;
box3.addChild(clear);
}
}
However, whenever I click on the button that activates the clear_filter function, the clear button disappears from the stage from the stage. I thought that this means that then when I call the clear_create() again with another button from the app, it would give me the clear button back. Instead, I get the Alert.show message pop up from what I have in the code where it should only appear if the clear button is on the stage.
What have I done wrong here?
Is this how I should check if an element exist on the stage?
Thanks for your help.