Private function changeFontColor(e:ColorPickerEvent):voidįmt.color = "0x" + fontColorPicker.hexValue These functions will handle the color pickers for the background and the text. Private function cancel(e:MouseEvent):void Tween = new Tween(txt,"y",Elastic.easeOut,txt.y,txt.y - 85,1,true) Tween = new Tween(fontsMenu,"x",Elastic.easeOut,stage.stageWidth / 2,stage.stageWidth + fontsMenu.width,2,true) Private function choosed(e:ListEvent):void This will hide the font choosing menu and set back the position of the TextInput. When you're sure of the font you want to use, you can double-click it or use the close button. When you click a font name in the List component the TextInput will automatically change the font to the selected one.įmt.font = new String(e.) ShowColorPicker(true) //Show the color pickers Tween = new Tween(txt,"y",Elastic.easeOut,txt.y,txt.y + 85,1,true) Į.target.visible = false //Hide the info button Tween = new Tween(fontsMenu,"x",Elastic.easeOut, - fontsMenu.width,stage.stageWidth / 2,1,true) * Animate the fonts panel and the textInput*/
Private function showFonts(e:MouseEvent):void
FONT PICKER FOR WINDOWS CODE
Remember the info button? That's the button we created to show the fonts menu, this code will take care of that. * Convert the Fonts Objects to Strings */įor (var i:int = 0 i < systemFonts.length i++)į = new DataProvider(fontNames) Īt the end of this function we'll have a List Component filled with all the installed fonts! Step 15: Info Button Actions SystemFonts.sortOn("fontName") //Sorts the font by name SystemFonts = Font.enumerateFonts(true) //Returna an array of the installed fonts With this function we only need to specify a parameter to show or hide the color picker text and components. Private function showColorPicker(val:Boolean):void This is the constructor function, it calls the starting functions.
Private var fmt:TextFormat = new TextFormat() //Textformat of the TextInput Private var fontNames:Array = new Array() //Will store all the system fonts as Strings Step 11: Variables private var systemFonts:Array = new Array() //Will store all the system fonts Import Step 10: Extending the Class public class Main extends SpriteĪltough we're using MovieClips, we extend the class using Sprite because the MovieClips on stage are not using a Timeline therefore they're treated as Sprites. Step 9: Importing the Necessary ClassesĬreate a new ActionScript file and import the necessary classes: In this application we're going to use a single class that will take care of all the elements in the stage, animations and color.Ĭreate a new ActionScript file and save it as Main.as in your classes folder.