zoukankan      html  css  js  c++  java
  • 个人总结flex各种用法


    //获得屏幕的分辨率

    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;

     

    //日期中文标题

    <mx:DateChooser  id=" dtchoose " x=" 219 " y=" 83 " dayNames=" [ , , , , , , ] " monthNames=" [ 一 月 , 二 月 , 三 月 , 四 月 , 五 月 , 六 月 , 七 月 , 八 月 , 九 月 , 十 月 , 十 一月 , 十 二月 ] "   change="disDate()" minYear=" 2007 " />

    // 选择日期  dateChoose

    function  disDate(): void {

    txtDate.text=fm.format(dtchoose.selectedDate.toLocaleDateString());

    }

     

    //flex 中添加html标记

    <mx:TextArea  id=" text " creationComplete="init()" width=" 248 " height=" 59 " >

    <mx:htmlText>

    <![CDATA[

    <input type='file'/>

    <a href="http://www.baidu.com"> 你 哈 !!!</a>

    ]]>

    </mx:htmlText>

    </mx:TextArea>

     

    //flex 带下划线的链接

    this .lblLink.htmlText= "<a href='http://www.google.com' target='_blank'>   </a>" ;
    <mx:Label  x=" 524 " y=" 393 " text=" Hellollll " id=" lblLink " rollOver="focusManager.deactivate()" color=" blue " opaqueBackground=" #ffffff "

     rollOut="focusManager.activate()" styleName=" Label "

     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 );

    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= " " ;

    }

    }

     

    <mx:Button  x=" 62 " y=" 80 " label=" Button " click="test()" />

    <mx:Label  x=" 62 " y=" 37 " text=" Label " width=" 65 " id=" lbl " />

     

    //flex Com bo box添加  请选择-

    private   function  loadCB(){

    var  arr:Array= new  Array( "- 请选择 -" );

    for ( var  i:int=1;i<10;i++){

    arr[i]=i;

    }

    this .cb.dataProvider=arr;

    }

     

     

    //combobox 选择的值和下标

    private   function  selected(): void {

    Alert.show(cb.selectedItem.toString()+ " 下标 :" +cb.selectedIndex);

    }

    <mx:ComboBox  x=" 194 " y=" 80 " id=" cb " creationComplete="loadCB()"   change="selected()" >

     

    //鼠标移动变大,Button加图片,变手型

    <mx:Button  x=" 72 " y=" 80 " label=" Button " click="test()" mouseMove="changBig()" mouseOut="changSmall()" id=" btn " height=" 52 " icon=" @Embed(source='img/3.jpg') "

     labelPlacement=" bottom " width=" 67 " useHandCursor=" true " buttonMode=" true " />

     

    private   function  changBig(): void {

    this .btn.scaleX=1.5;

    this .btn.scaleY=1.5

    }

    private   function  changSmall(): void {

    this .btn.scaleX=1;

    this .btn.scaleY=1;

    }

     

    //flex panel 拖动效果

    <mx:Panel  x=" 194 " y=" 125 " width=" 192 " height=" 121 " layout=" absolute " id=" panel " mouseDown="ondragStart(event)" mouseUp="ondragStop(event)" >

    </mx:Panel>

    private   function  ondragStart(event:MouseEvent): void {

    Panel(event.target).startDrag();

    }

    private   function  ondragStop(event:MouseEvent): void {

    Panel(event.target).stopDrag();

    }

     

    // 写入共享数据

    share=SharedObject.getLocal( "username" );

    share.data.userName=txtUser.text;

    share.flush();

     

    //读取共享数据

    var  share:SharedObject=SharedObject.getLocal( "username" );

    Alert.show(share.data.userName);

     

     

     

     

     

     

     

    //jsp/html文件嵌入到flex中(需要把 flexiframe.swc 放在项目的flex_libs下)

     

    A pplication标签内 xmlns:code= http://code.google.com/p/flex-iframe/

     

    <mx:HDividedBox  x=" 0 " y=" 10 " width=" 100% " height=" 500 " >

    <mx:Panel  width=" 30% " height=" 500 " layout=" absolute " >

     

    </mx:Panel>

    <mx:Panel  width=" 70% " height=" 500 " layout=" absolute " >

    <code:IFrame id="frm" source="file/ 万年历 .html" height="100%" width="100%"/> <!-这是最重要的- à

    </mx:Panel>

    </mx:HDividedBox>

     

    //检查使用的操作系统

    private   function  checkOS(): void {

    var  os:String=Capabilities.os;

    tt.text= " 你的操作系统是 :--" +os;

    }

     

    //检查所使用的浏览器

    private   function  checkPlay(): void {

    var  play:String=Capabilities.playerType;

    Alert.show(play);

    if (play== "ActiveX" ){

    tt.text= " 你的浏览器是 --IE" ;

    } else   if (play== "PlugIn" ){

    tt.text= " 你的浏览器是 --Mozilla-Firefox" ;

    } else {

    tt.text= " 你的浏览器是 -- 其他 " ;

    }

    }

     

    //检查player的版本和使用的语言

    private   function  other(): void {

    var  v:String=Capabilities.version;

    var  l:String=Capabilities.language;

    tt.text= " 你的 flayer 版本号: --" +v+

    "\r\n 你的语言是: --" +l;

    }

     

    //改变鼠标样式

    [ Bindable ]

    [ Embed (source= "img/157.jpg" )]

    public   var  cur:Class;

    private   function  initCursor(event:Event){

    CursorManager.setCursor(cur);

    }

     

    //设置 AdvancedDataGrid 的表头竖线为空

    headerSortSeparatorSkin=" mx.skins.ProgrammaticSkin "

     

     

     

     

     

    //获得鼠标坐标

    var  cx:Number=CursorManager.currentCursorXOffset;

    var  cy:Number=CursorManager.currentCursorYOffset;

    var  id:int=CursorManager.currentCursorID;

    Alert.show( "x:=" +cx+ "y:=" +y+ "id=" +id);

  • 相关阅读:
    入门系列4
    入门系列3
    入门系列2
    入门系列1
    sql进阶-筛选库表中数据为空的表
    sql进阶-删除所有的视图
    sql序列(2) sql语句功能表
    sql序列(5)事务
    sql序列(4)存储过程
    KVM虚拟化介绍
  • 原文地址:https://www.cnblogs.com/nianshi/p/1768038.html
Copyright © 2011-2022 走看看