StageText gives the possibility to use native text input controller which has more powerful features like auto-complete. But sometime it is just too difficult to use. Some guys from Adobe gives a NativeText class which wraps the StageText and add some fancy features. Here is the description:
- It makes StageText feels like it’s part of the display list. You can create an instance of NativeText, give it x and ycoordinates, and add it to the display list just like you would any other display object. All the management of the
viewPortis completely encapsulated.
- It’s easy to add borders. NativeText does the work of drawing borders such that the StageText instance is vertically centered and horizontally bound. You can even change the border’s thickness, color, and corner radius.
- It’s easy to add content on top because it manages the bitmap swapping for you. NativeText has a function called
freezewhich does all the work of drawing the StageText to a bitmap (including the border), hiding the StageText instance, and positioning the bitmap exactly where the StageText was. Therefore, if you want to place content on top of a NativeText instance (for instance, an alert box), just call the
freezefunction first, and everything will work perfectly. When you’re done, call
unfreeze, and the bitmap is replaced with the StageText instance and disposed of.
- Support for multi-line text inputs. NativeText supports text fields of one or more lines. Just pass the number of lines of text you want into the constructor (this is the one property that cannot be changed dynamically), and both the border and
viewPortwill be properly managed for you.
- Cross platform. The trickiest part of writing NativeText was making sure it rendered properly on all our reference platforms (Mac, Windows, iOS, and Android) which use different fonts, have different sized cursors, etc. NativeText lets you use any font, font size, and border thickness you want, and your text input should render properly and consistently on all supported platforms.