これでうまくいくと思った...
var bFormat:TextFormat, bStartText:TextField, bQuitText:Textfield;
bFormat = getFormat();
bStartText = getText("Start");
bStartText.defaultTextFormat = bFormat;
bQuitText = getText("Quit");
bQuitText.defaultTextFormat = bFormat;
stage.addChild(bStarText);
stage.addChild(bQuitText);
function getFormat():TextFormat {
var bFormat:TextFormat = new TextFormat();
bFormat.font = "Arial";
bFormat.color = 0X000000;
bFormat.size = 28;
bFormat.align = "center";
return bFormat;
}
function getText(sText):TextField {
var bText:TextField = new TextField();
bText.text = sText;
bText.x = -4;
bText.y = 4;
return bText;
}
両方のテキストフィールドがステージに表示されますが、getFormat()で指定されたフォーマットが取得されません。getFormat()のコードを(独自の関数としてではなく)メインコードに配置しましたが、正常に機能します。私はそれを間違って渡しますか?