Advertisement
Advertisement
| 05.16.2008 at 10:09AM PDT, ID: 23409054 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: |
// MenuItems.as
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;
import flash.media.Sound;
import flash.net.URLRequest;
public class MainMenuItem extends MovieClip {
private var movMenuBox : MovieClip;
private var txtfMenuFont : TextFormat;
private var txtMenuText : TextField;
private var clrMenuColo : uint;
private var isGone : Boolean;
private var twMenuTween : Tween;
private var sndMenuOverSound: Sound;
public function MainMenuItem(menuLabel : String, menuColor : uint) : void {
clrMenuColo = menuColor;
constructItem(menuLabel);
sndMenuOverSound = new Sound(new URLRequest("sounds/menubip.mp3"));
}
private function constructItem(menuLabel : String) : void {
txtfMenuFont = new TextFormat();
txtfMenuFont.font = new menuFont().fontName;
txtfMenuFont.size = 8;
txtfMenuFont.color = 0xffffff;
txtMenuText = new TextField();
txtMenuText.defaultTextFormat = txtfMenuFont;
txtMenuText.embedFonts = true;
txtMenuText.text = menuLabel;
txtMenuText.autoSize = TextFieldAutoSize.LEFT;
txtMenuText.selectable = false;
txtMenuText.mouseEnabled = false;
movMenuBox = new MovieClip();
movMenuBox.graphics.beginFill(clrMenuColo);
movMenuBox.graphics.drawRect(0,2, 200, 10);
movMenuBox.graphics.endFill();
movMenuBox.width = 200;
movMenuBox.height = 20;
addChild(movMenuBox);
movMenuBox.addChild(txtMenuText);
txtMenuText.addEventListener(MouseEvent.MOUSE_OVER, overMenuEvent);
txtMenuText.addEventListener(MouseEvent.MOUSE_OUT, outMenuEvent);
movMenuBox.addEventListener(MouseEvent.MOUSE_OVER, overMenuEvent);
movMenuBox.addEventListener(MouseEvent.MOUSE_OUT, outMenuEvent);
}
private function overMenuEvent(e : MouseEvent):void{
twMenuTween = new Tween(this,"alpha",Regular.easeIn,1,0.6,10);
sndMenuOverSound.play();
}
private function outMenuEvent(e:MouseEvent):void{
twMenuTween.yoyo();
}
}
}
|