apache flex - mx:HTML 控件在代码隐藏中添加时不会显示



我正在构建一个AIR应用程序,我计划包括mx:HTML控件,但我似乎无法获得控件显示。下面是代码:

var tmpHtml:HTML = new HTML();
tmpHtml.htmlText = "<a>This is the sample </a>";
tmpHtml.x = 48;
tmpHtml.y = 10;
tmpHtml.width = 360;
tmpHtml.height = 169;
tmpHtml.visible = true;
stage.addChild(tmpHtml);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addChild(txt);

您需要将tmpHtml添加到应用程序,而不是舞台。