ラベルが入ったBorderContainerがあります。このラベルをコンテナの中央に配置する必要があります。BorderContainerにはレイアウトがありません(デフォルトのbasicLayoutを取得すると思います...)。
私のコード:
BorderContainerの定義:
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="bordercontainer1_creationCompleteHandler(event)"
addedToStage="bordercontainer1_addedToStageHandler(event)"
cornerRadius="200" borderWeight="20" >
BorderContainerが完了すると、ラベルを動的にロードします。
protected function bordercontainer1_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
var countdownText:Label = new Label();
countdownText.width = this.width * 0.5;
//countdownText.height = this.height * 0.5;
countdownText.text =String( countdownDuration );
countdownText.setStyle("fontSize","200");
countdownText.setStyle("fontFamily", "Arial");
countdownText.setStyle("color","#FF0000");
countdownText.setStyle("fontWeight", "bold" );
countdownText.setStyle("textAlign", "center");
this.addElement(countdownText);
//trace("width border:", this.width, ", text width:", countdownText.width);
countdownText.x = (this.width-countdownText.width)/2;
countdownText.y = (this.width-countdownText.width)/2;
}
このコードでは、ラベルのテキストはコンテナの中央に配置されますが、BorderWeightプロパティを設定すると、テキストがシフトします!!!!!
よろしくお願いします。