During a Project which had to handle large amounts of BitmapData-Objects i had problems in displaying dynamically created TextFields in the DisplayList. TextFields were not visible on stage, even though the properties were all correct.
Surpisingly i could add other Bitmap-Objects, which are displayed correct, so i used this workaround:
// note: Application.getInstance().getTextFieldTextBounds( textField ) returns the correct amount of space taken from the textField according to http://blog.derraab.com/2010/05/16/aligning-flash-textfield-instances-visually-correct/ // create new BitmapData Object using the TextFields bounds and use alpha values var bm : BitmapData = new BitmapData( Application.getInstance().getTextFieldTextBounds( tf ).width + 20, Application.getInstance().getTextFieldTextBounds( tf ).height + 20, true, 0x00000000 ); // take a SnapShot of the TextField bm.draw( tf ); // create new Bitmap Object var bitmap : Bitmap = new Bitmap( bm ); bitmap.x = tf.x; bitmap.y = tf.y; // deleting the reference TextField tf = null; // adding new Bitmap to a Sprite s.addChild( bitmap ); |