Graphics Reference
In-Depth Information
for the upstate (when the mouse is not over the button), the overstate,
and the downstate. For example, you may want to show your menu
using Arial font with no underlines until a user rolls his or her mouse
over a button. The other modifiable style in the SimpleMenu class is
the rectangle that is drawn behind the text of each button. You can
control the opacity of the rectangle in the different states with the
backgroundUpAlpha, backgroundDownAlpha ,and backgroundDownAlpha
properties to have it semi see-through (or set their value to 0 and get
rid of the rectangle altogether). Additionally, you can control the color
of the rectangle separately for each state as well. Once the Simple-
Menu class is used to create a menu in your project, you can assign
any function to any button within that menu by using the assign
Action method.
SimpleMenu Code
package com.flashadbook.display {
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
public class SimpleMenu extends Sprite {
// ——— layout options for the menu
public static var HORIZONTAL:String = " horizontal " ;
public static var VERTICAL:String = " vertical " ;
private var _layout:String; // used to hold the
chosen layout
private var _spacing:Number; // the amount of space
between menu items
private var _menuItem:Sprite; // used to create and
alter individual menu items
private var _menuItemLabel:TextField; // used to
create and alter individual menu item labels
// ——— background color
private var _upBackground:uint = 0x000000;
private var _overBackground:uint = 0x000000;
private var _downBackground:uint = 0x000000;
// ——— background alpha
private var _backgroundUpAlpha:Number = 1.0;
private var _backgroundOverAlpha:Number = 0.5;
private var _backgroundDownAlpha:Number = 0.0;
// ——— label text format
private var _labelFormatUp:TextFormat = new
TextFormat();
Search WWH ::




Custom Search