zoukankan      html  css  js  c++  java
  • 用[Bindable]标签声明和用{}语法绑定属性

    Bindable]标签用来声明属性是可以绑定的。

    1,在类前写[Bindable]声明所有的public属性,var 声明的或者getter/setter是可以绑定的
    [Bindable]
    class AllBindable{
        public var variable;
        public function set accessor(v:Object):void{
           ......
        }
        public function get accessor():Object{
           ......
        }
        //No you are NOT public
        protected var protectedProperty;
        //No you are NOT public
        private var privateProperty;
    }
    上边的类中variable和accessor是可以绑定的,protectedProperty和privateProperty还不是。
    2,在公有的实例变量或者类变量前写[Bindable],声明它是可以绑定的。这里的“变量”特指使用 var 声明的。
    [Bindable]
    public var variable;
    3,getter/setter。单独的getter定义一个只读的属性,只读的属性不必被声明为可绑定的,帮助文档的解释是他们通常是不变的所以可以当作他们已经被声明为bindable一样的来使用(可是我觉得只读和不变还是有区别的)。单独的setter定义一个只写的属性,只写属性不能被绑定,这个容易理解,因为 : <...source="{??? unreadable --b}" .../>
    一组getter/setter定义一个读写的属性。使用[Bindable]声明的属性是getter/setter定义的这种情况,应该把标签写到这组定义的前面。
    //[Bindable] 一个正确的位置,虽然标签对私有的变量不起作用,但是为了防止记忆上的疲劳,[url=javascript:;]推荐[/url]写到下边
    private var _property
    [Bindable]  //这是编辑器推荐的位置,紧挨着getter/setter,我要附和一下
    //
    protected function set property(v:Object):void{
        _property = v;
    }
    protected function get property():Object{
        return _property;
    }

  • 相关阅读:
    Monkey写脚本
    Appium+JAVA初试牛刀之安装APP
    新安家啦
    SRAM速度提升思路及方法
    FIR滤波器工作原理(算法)以及verilog算法实现(包含与IIR的一些对比)
    I2C总线协议详解
    有符号二进制加法溢出判断以及溢出后该如何计算正确答案
    Verilog 编写规范
    Android中锁屏密码算法解析以及破解方案
    IIS中查看W3P.exe进程对应的应用程序池的方法
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/1608591.html
Copyright © 2011-2022 走看看