void Start ( ) { BMFontReader.registerFonts( bmFonts ); // Font linkage from swf using font name & size mapping stage.addChild( new MovieClip("uniSWF/Examples/Extra examples/BMFont reader/swf/bmfonttest.swf:Font") ); // Add Text to stage TextFormat format = new TextFormat(); format.font = "Times Bold"; format.color = Color.green; format.size = 64; BitmapTextField txt = new BitmapTextField( ); txt.width = 500; txt.height = 200; txt.textFormat = format; txt.text = "BMText set from code"; txt.y = 100; txt.x = 10; txt.type = TextFieldType.INPUT; txt.addCharColor( 7, 9, Color.cyan ); txt.addCharColor( 16, 19, Color.red ); txt.appendText( ", Appended text" ); stage.addChild( txt ); }
void Start ( ) { // // Alter existing font // Add root with single textfield mc = new MovieClip( "uniSWF/Examples/Extra examples/ProgramaticTextFields/swf/programaticText.swf:Root" ) ; stage.addChild( mc ); // Ensure player is not changing textfields on timeline mc.stop(); // Get textfield txt = mc.getChildByName<TextField>( "txt" ); // Get format TextFormat format = txt.textFormat; // Set new format format.fontClassName = null; // Clear class for bitmap fonts as this points to the exact font_size_filters assets format.size = 30; // Set format txt.textFormat = format; // // Add new textfield using font and size ( must be exported ) format = new TextFormat(); format.font = "Times Bold"; format.color = Color.green; format.size = 64; BitmapTextField bmpTxt = new BitmapTextField( ); bmpTxt.width = 500; bmpTxt.height = 200; bmpTxt.textFormat = format; bmpTxt.text = "Text set from code"; bmpTxt.y = 100; bmpTxt.x = 10; bmpTxt.type = TextFieldType.INPUT; bmpTxt.addCharColor( 5, 8, Color.cyan ); bmpTxt.addCharColor( 14, 17, Color.red ); bmpTxt.appendText( ", Appended text" ); stage.addChild( bmpTxt ); }