The control is intended to represent a local date and time, not necessarily the user's local date and time. In browsers with no support, these degrade gracefully to simple controls. This is a very useful app for testing fonts, using this tut you can create your own app to satisfy your specific needs.The control's UI varies in general from browser to browser. Test the movie and see your Font Picker application run! Conclusion Go back to the Fla document, open the properties panel and in the "class" textfield write "Main" to link this as the Document Class. InfoButton.addEventListener(MouseEvent.MOUSE_UP, showFonts) į(Event.CHANGE, onChange) į(ListEvent.ITEM_DOUBLE_CLICK, choosed) įontColorPicker.addEventListener(ColorPickerEvent.CHANGE, changeFontColor) īgColorPicker.addEventListener(ColorPickerEvent.CHANGE, changeBgColor) į(MouseEvent.MOUSE_UP, cancel) This function was called in the constructor. Var colorTransform:ColorTransform = new ColorTransform() Ĭlor = int("0x" + bgColorPicker.hexValue) īg.lorTransform = colorTransform Ĭreate a function to add all the listeners at the same time. Private function changeBgColor(e:ColorPickerEvent):void 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 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |