主要有三个静态方法,分别用来初始化舞台、右键菜单及字体样式
package utils{
import flash.display.DisplayObjectContainer;
import flash.display.Stage;
import flash.display.StageScaleMode;
import flash.events.ContextMenuEvent;
import fl.managers.StyleManager;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.text.TextFormat;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
/**
* @author Flying
*/
public class Initializer {
/**
* @param owner 父级容器
*/
public static function initStage(owner : DisplayObjectContainer) : void {
owner.stage.scaleMode = StageScaleMode.NO_SCALE;
}
public static function initContextMenu(owner:DisplayObjectContainer):void {
var my_cm:ContextMenu = new ContextMenu();
my_cm.hideBuiltInItems();
var email_cmi:ContextMenuItem = new ContextMenuItem("Made by Flying");
email_cmi.addEventListener(ContextMenuEvent.MENU_ITEM_Select, getEmailHandler);
var site_cmi:ContextMenuItem = new ContextMenuItem("Supported by riafan.com");
site_cmi.addEventListener(ContextMenuEvent.MENU_ITEM_Select, getURLHandler);
my_cm.customItems.push(email_cmi);
my_cm.customItems.push(site_cmi);
owner.contextMenu = my_cm;
}
private static function getEmailHandler(event:ContextMenuEvent):void {
navigateToURL(new URLRequest("mailto:jimllf@163.com"),"_self");
}
private static function getURLHandler(event:ContextMenuEvent):void {
navigateToURL(new URLRequest("http://www.riafan.com/"), "_blank");
}
public static function initStyle():void {
var tf:TextFormat = new TextFormat;
tf.size = 12;
StyleManager.setStyle("textFormat",tf);
}
}
}