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

  • 相关阅读:
    教程:在 Visual Studio 中开始使用 Flask Web 框架
    教程:Visual Studio 中的 Django Web 框架入门
    vs2017下发现解决python运行出现‘No module named "XXX""的解决办法
    《sqlite权威指南》读书笔记 (一)
    SQL Server手工插入标识列
    hdu 3729 I'm Telling the Truth 二分图匹配
    HDU 3065 AC自动机 裸题
    hdu 3720 Arranging Your Team 枚举
    virtualbox 虚拟3台虚拟机搭建hadoop集群
    sqlserver 数据行统计,秒查语句
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/1608591.html
Copyright © 2011-2022 走看看