Recently i saw statement like this "HBox( this.getChildAt(0) )"
What does it really mean , 开发者_开发知识库I never used HBox( some argument ); ? i saw such statement in some class inherits WindowShade control. Please clear this doubt.Thanks!
That statement is a cast. It's used when you have an object with a very generic type that you absolutely know is a more specific type - in this case, probably a DisplayObject or interface type that you know is an HBox, which you want to call the methods of HBox on.
You should only use a cast if you're absolutely sure that you're casting to the correct type, as casting to the wrong type will throw an error. If you're not sure that you have an HBox, you can use the "as" syntax:
var myHBox:HBox = thing as HBox;
if(myHBox)
{
...
}
This way, if thing isn't an HBox, myHBox will be set to null.
精彩评论