Oops, new to the forums. Sorry for the messed up formatting. I assumed BB Code would work here, for some reason.
1 person found this helpful
With spark addChild has been replaced with addElement..
Also you need to set where the panel is placed and its size, you can use real co-ordinates or set layout like top/left/bottom/right
Thanks for the answer. Sadly, I'm not there yet.
The reason I had moved from addElement to addChild is that addElement gives the error:
1061: Call to a possibly undefined method addElement through a reference with static type ActionScript:MySpecialButton.
This occurs even when setting the dimensions of the panel before trying to add it.
I think the parent panel should be responsible for adding the new panel. And also , why are you overriding clickHandler ? Try taking the responsibility of adding children to the parent from the button and try adding itto the parent. Below is some pseudo code of what I mean.
public function buttonClicked( event:Event ):void
var newPanel:NewPanel = new NewPanel();
addElement( newPanel );
<Button click="buttonClicked(event)" />
I didn't want to accept it, but you're right, I should be doing this through the parent. I was hoping to be able to reuse these buttons throughout my application, on various pages, without having to write panel-making functions on each, but that's probably not a good idea, in addition to not working.