个人总结flex各种用法
转自获得屏幕的分辨率varx:number=capabilities.screenresolutionx;
vary:number=capabilities.screenresolutiony;
alert.show("x="+x+"y="+y);
第二种方法
alert.show(stage.fullscreenwidth+"=="+stage.fullscreenheight);
//获得stage(工作区)的宽、高
alert.show(stage.stagewidth+"=="+stage.stageheight);
//读取xml文件privatefunctionreadxml2:void
{
varurlrequest:urlrequest=newurlrequest("file/stu.xml");
varurlloader:urlloader=newurlloader(urlrequest);
urlloader.addeventlistener(event.complete,completehandler);
}
privatefunctioncompletehandler(event:event):void
{
varxml:xml=newxml(event.target.data);
//vararr:array=newarray(xml);
this.dg.dataprovider=xml.children;
this.tree.dataprovider=xml;
this.cb.dataprovider=xml.children;
//this.hlist.dataprovider=xml.children;
}
//flex获得系统路径
varadd:string=externalinterface.call("window.location.href.tostring",1);
alert.show(add);
//背景颜色不断变化
privatefunctionchangebg:void{
varmytime:timer=newtimer(2000);
mytime.addeventlistener(timerevent.timer,changhandle);
mytime.start;
}
privatefunctionchanghandle(e:timerevent):void{
this.setstyle("backgroundcolor",math.random*0xffffff);
}
//获得键盘按下的键的值
publicfunctiongetcode:void
{
btn.addeventlistener(keyboardevent.key_down,keyhandle);
}
functionkeyhandle(event:keyboardevent):void
{
alert.show("你按下了:"+string.fromcharcode(event.charcode));
}
//动态加载不同界面
importcommont.two;
importcommont.one;
vart:two=newtwo;
varo:one=newone;
privatefunctionshowone:void{
tw.removeallchildren;
tw.addchild(o);
}
privatefunctionshowtwo:void{
tw.removeallchildren;
tw.addchild(t);
}
//flex绑定图片
[bindable]
(未完,全文共5211字,当前显示1485字)
(请认真阅读下面的提示信息)