Game Development Reference
In-Depth Information
Labels, text fields, and sprite buttons
A must have feature for any game, especially right at the beginning if you are
writing a multiplayer game! How else would you have players log in?
Here is the listing of a sample login screen with compiler options: -default-size
800 600 -default-background-color 0x000000
package {
import fl.controls.TextInput;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import mx.core.BitmapAsset;
public class LoginScreen extends Sprite
{
// Create access for the button images
[Embed(source="ok.png")]
private var OK:Class;
[Embed(source="exit.png")]
private var Exit:Class;
// Text format for all labels and text input
private var m_format:TextFormat = new TextFormat();
// Label and text input for the username
private var m_userLabel:TextField = new TextField();
private var m_username:TextInput = new TextInput();
// Label and text input for the password
private var m_passLabel:TextField = new TextField();
private var m_password:TextInput = new TextInput();
public function LoginScreen()
{
// Initialize the format
m_format.font = "arial";
m_format.size = "10";
m_format.color = 0xaaaaaa;
// Initialize and add username label
m_userLabel.defaultTextFormat = m_format;
m_userLabel.x = 172; m_userLabel.y = 100;
m_userLabel.text = "Username:";
addChild(m_userLabel);
 
Search WWH ::




Custom Search