个人总结flex各种用法
2009年11月03日
//获得屏幕的分辨率
var x:Number=Capabilities.screenResolutionX;
var y:Number=Capabilities.screenResolutionY;
Alert.show("x="+x+"y="+y);
第二种方法
Alert.show(stage.fullScreenWidth+"=="+stage.fullScreenHeight);
//获得stage(工作区)的宽、高
Alert.show(stage.stageWidth+"=="+stage.stageHeight);
//读取xml文件
private function readxml2():void
{
var urlrequest:URLRequest=new URLRequest("file/stu.xml");
var urlloader:URLLoader=new URLLoader(urlrequest);
urlloader.addEventListener(Event.COMPLETE, completehandler);
}
private function completehandler(event:Event):void
{
var xml:XML=new XML(event.target.data);
// var arr:Array=new Array(xml);
this.dg.dataProvider=xml.children();
this.tree.dataProvider=xml;
this.cb.dataProvider=xml.children();
// this.hlist.dataProvider=xml.children();
}
//flex 获得系统路径
var add:String=ExternalInterface.call("window.location.href.toString",1);
Alert.show(add);
//背景颜色不断变化
private function changeBG():void{
var mytime:Timer=new Timer(2000);
mytime.addEventListener(TimerEvent.TIMER,changHandle);
mytime.start();
}
private function changHandle(e:TimerEvent):void{
this.setStyle("backgroundColor",Math.random()* 0xffffff);
}
//获得键盘按下的键的值
public function getCode():void
{
btn.addEventListener(KeyboardEvent.KEY_DOWN, keyHandle);
}
function keyHandle(event:KeyboardEvent):void
{
Alert.show("你按下了:" + String.fromCharCode(event.charCode));
}
//动态加载不同界面
import commont.Two;
import commont.One;
var t:Two=new Two();
var o:One=new One();
private function showOne():void{
tw.removeAllChildren();
tw.addChild(o);
}
private function showTwo():void{
tw.removeAllChildren();
tw.addChild(t);
}
//flex 绑定图片
[Bindable]
[Embed(source="img/1.jpg")]
public var phone1:Class;
//日期中文标题
//选择日期 dateChoose
function disDate():void{
txtDate.text=fm.format(dtchoose.selectedDate.toLocaleDateString());
}
//flex 中添加html标记
你哈!!!
]]>
//flex 带下划线的链接
this.lblLink.htmlText="新 闻";
.Label{text-roll-over-color:red; text-decoration:underline; background-color:green; font-size:12px; text-selected-color:red;}
//flex 转向 URL
Var url:URLRequest=new URLRequest(“http://www.google.cn”);
navigateToURL(url,”_self”);//在本页打开
navigateToURL(url,”_blank”);//在新的一页打开
//弹出对话框
---------非模式打开---------
PopUpManager.createPopUp(this,类(界面)的名称);
---------模式打开---------
var ep:Main=new Main ();
PopUpManager.addPopUp(ep,this,true);//界面,打开窗口父类,是否模式
PopUpManager.centerPopUp(ep);//在父类窗口居中
//-----Alert的用法
public function test():void
{
var glow:GlowFilter=new GlowFilter();
glow.color=StyleManager.getColorName("blue");//边框颜色
glow.strength=5;
glow.alpha=0.8;
var alert:Alert=Alert.show("是否选择","提示",Alert.YES|Alert.NO,this,alertHandle);
alert.filters=[glow];
}
private function alertHandle(event:CloseEvent):void{
if(event.detail==Alert.YES){
lbl.text="是";
}else{
lbl.text="否";
}
}
//flex Combobox添加
2009年11月03日
//获得屏幕的分辨率
var x:Number=Capabilities.screenResolutionX;
var y:Number=Capabilities.screenResolutionY;
Alert.show("x="+x+"y="+y);
第二种方法
Alert.show(stage.fullScreenWidth+"=="+stage.fullScreenHeight);
//获得stage(工作区)的宽、高
Alert.show(stage.stageWidth+"=="+stage.stageHeight);
//读取xml文件
private function readxml2():void
{
var urlrequest:URLRequest=new URLRequest("file/stu.xml");
var urlloader:URLLoader=new URLLoader(urlrequest);
urlloader.addEventListener(Event.COMPLETE, completehandler);
}
private function completehandler(event:Event):void
{
var xml:XML=new XML(event.target.data);
// var arr:Array=new Array(xml);
this.dg.dataProvider=xml.children();
this.tree.dataProvider=xml;
this.cb.dataProvider=xml.children();
// this.hlist.dataProvider=xml.children();
}
//flex 获得系统路径
var add:String=ExternalInterface.call("window.location.href.toString",1);
Alert.show(add);
//背景颜色不断变化
private function changeBG():void{
var mytime:Timer=new Timer(2000);
mytime.addEventListener(TimerEvent.TIMER,changHandle);
mytime.start();
}
private function changHandle(e:TimerEvent):void{
this.setStyle("backgroundColor",Math.random()* 0xffffff);
}
//获得键盘按下的键的值
public function getCode():void
{
btn.addEventListener(KeyboardEvent.KEY_DOWN, keyHandle);
}
function keyHandle(event:KeyboardEvent):void
{
Alert.show("你按下了:" + String.fromCharCode(event.charCode));
}
//动态加载不同界面
import commont.Two;
import commont.One;
var t:Two=new Two();
var o:One=new One();
private function showOne():void{
tw.removeAllChildren();
tw.addChild(o);
}
private function showTwo():void{
tw.removeAllChildren();
tw.addChild(t);
}
//flex 绑定图片
[Bindable]
[Embed(source="img/1.jpg")]
public var phone1:Class;
//日期中文标题
//选择日期 dateChoose
function disDate():void{
txtDate.text=fm.format(dtchoose.selectedDate.toLocaleDateString());
}
//flex 中添加html标记
你哈!!!
]]>
//flex 带下划线的链接
this.lblLink.htmlText="新 闻";
.Label{text-roll-over-color:red; text-decoration:underline; background-color:green; font-size:12px; text-selected-color:red;}
//flex 转向 URL
Var url:URLRequest=new URLRequest(“http://www.google.cn”);
navigateToURL(url,”_self”);//在本页打开
navigateToURL(url,”_blank”);//在新的一页打开
//弹出对话框
---------非模式打开---------
PopUpManager.createPopUp(this,类(界面)的名称);
---------模式打开---------
var ep:Main=new Main ();
PopUpManager.addPopUp(ep,this,true);//界面,打开窗口父类,是否模式
PopUpManager.centerPopUp(ep);//在父类窗口居中
//-----Alert的用法
public function test():void
{
var glow:GlowFilter=new GlowFilter();
glow.color=StyleManager.getColorName("blue");//边框颜色
glow.strength=5;
glow.alpha=0.8;
var alert:Alert=Alert.show("是否选择","提示",Alert.YES|Alert.NO,this,alertHandle);
alert.filters=[glow];
}
private function alertHandle(event:CloseEvent):void{
if(event.detail==Alert.YES){
lbl.text="是";
}else{
lbl.text="否";
}
}
//flex Combobox添加