读书人

个人小结flex各种常用代码

发布时间: 2012-07-30 16:19:05 作者: rapoo

个人总结flex各种常用代码

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

读书人网 >flex

热点推荐