daljit.kumar
11-08-2009, 06:37 PM
Hey Guys,
I have this very simple code snippet which does not work fine. It simply shows a white rectangle without any text in it. I have searched for this on net and this seems to be the correct way of doing it. Any idea why it is not working?
numberText = new Text();
numberText.width = 100;
numberText.height = 100;
numberText.setStyle("horizontalCenter", true);
numberText.setStyle("fontSize", 18);
numberText.text = "Hello";
var bmd:BitmapData = new BitmapData(numberText.width, numberText.height);
var uiComp:UIComponent = new UIComponent();
bmd.draw(numberText);
uiComp.x = 500;
uiComp.y = 200;
uiComp.width = 100;
uiComp.height = 100;
uiComp.addChild(new Bitmap(bmd));
this.addChild(uiComp);
I have this very simple code snippet which does not work fine. It simply shows a white rectangle without any text in it. I have searched for this on net and this seems to be the correct way of doing it. Any idea why it is not working?
numberText = new Text();
numberText.width = 100;
numberText.height = 100;
numberText.setStyle("horizontalCenter", true);
numberText.setStyle("fontSize", 18);
numberText.text = "Hello";
var bmd:BitmapData = new BitmapData(numberText.width, numberText.height);
var uiComp:UIComponent = new UIComponent();
bmd.draw(numberText);
uiComp.x = 500;
uiComp.y = 200;
uiComp.width = 100;
uiComp.height = 100;
uiComp.addChild(new Bitmap(bmd));
this.addChild(uiComp);