`

Bound methods注意

    博客分类:
  • Flex
阅读更多
与JAVA的不同,flex里面的Bound methods.
Bound methods 定义如下:
   A bound method, sometimes called a method closure, is simply a method that is extracted from its instance.
和 Function Closure 的不同:
   The key difference, however, between a bound method and a function closure is that the this reference for a bound method remains linked, or bound, to the instance that implements the method.
  In other words, the this reference in a bound method always points to the original object that implemented the method. For function closures, the this reference is generic, which means that it points to whatever object the function is associated with at the time it is invoked。
调用的是bound method 时,那么该method 中的this 引用的是实现该方法的对象,并用该方法能够使用实现该方法的对象内的属性。。这一点和As2.0不同。
 
class ThisTest
{
private var num:Number = 3;
function foo():void // bound method defined
{
trace("foo's this: " + this);
trace("num: " + num);
}
function bar():Function
{
return foo; // bound method returned
}
}
var myTest:ThisTest = new ThisTest();
var myFunc:Function = myTest.bar();
trace(this); // output: [object global]
myFunc();
/* output:
foo's this: [object ThisTest]
output: num: 3 */

此代码中的全局this 和 Bound Function 里的this 引用的对象是不同的。
分享到:
评论

相关推荐

    Android Service之bound实现

    注意,如果服务是通过绑定方式启动的,当所有客户端都解绑后,系统可能会自动停止该服务。 Bound Service的优势在于能够实时通信,允许客户端和服务之间进行复杂的交互,如传递数据、调用服务中的方法等。但是,...

    JavaBean - Bound属性

    在JavaBean中,"Bound属性"是指那些当其值发生改变时,能够自动通知相关监听器和其他依赖组件的属性。这种特性使得JavaBean在Java应用程序和网页设计中(如JSP)特别有用,因为它简化了组件之间的交互。 在JavaBean...

    usb-bound分析器

    6. **安全注意事项**:理解在操作USB设备和分析USB数据时应遵循的安全措施,防止数据丢失或设备损坏。 通过深入学习和实践使用USB-bound分析器,不仅可以提升对USB设备的理解,还能增强在实际工作中解决USB相关问题...

    Projected Gradient Methods for Non-negative Matrix Factorization

    Projected Gradient Methods for Non-negative Matrix Factorization Chih-Jen Lin Department of Computer Science Abstract Non-negative matrix factorization (NMF) can be formulated as a minimization ...

    ADO Data Bound Class WizardADO数据类向导

    ADO Data Bound Class WizardADO数据类向导

    lower-bound函数用法及案例分享

    lower_bound函数lower_bound函数用法及应用领域和案例分享lower_bound函数用法及应用领域和案例分享lower_bound函数用法及应用领域和案例分享lower_bound函数用法及应用领域和案例分享lower_bound函数用法及应用领域...

    Upper confidence bound_python_Confidence_

    upper confidence bound implementation

    Tomcat启动时报错:Name salesDataSource is not bound in this Context

    Name salesDataSource is not bound in this Context,连接池的问题

    数据池连接Name jdbc is not bound in this Context解决方案

    在这个问题中,开发者遇到了一个常见的错误:“Name jdbc is not bound in this Context”,这通常意味着在Tomcat的环境中,指定的数据源没有被正确地绑定或配置。 要解决这个问题,首先需要在Tomcat的配置文件中...

    绑定服务BoundService详解之AIDL的使用(自定义属性也包含其中)

    在Android开发中,服务(Service)是四大组件之一,主要用于在后台执行长时间运行的任务,而绑定服务(Bound Service)则是服务的一种特殊形式,它允许其他组件(如Activity或BroadcastReceiver)通过接口与服务进行交互...

    lower-bound函数2.zip

    需要注意的是,`lower_bound`只能用于已排序的容器,如果容器中的元素没有排序,使用`lower_bound`可能会得到错误的结果。 在实际编程中,`lower_bound`常用于插入新元素而不破坏原有顺序,例如在`std::set`或`std:...

    lower-bound函数

    ### Lower_bound 函数详解 #### 一、概述 在 C++ 的 `<algorithm>` 标准库中,`lower_bound` 函数是一个非常实用且高效的工具,用于在一个已排序的序列中寻找特定值的插入位置,以确保序列继续保持有序状态。这...

    org.hibernate.HibernateException: No Hibernate Session bound to thread

    然而,在使用 Hibernate 进行数据库操作时,经常会遇到 "No Hibernate Session bound to thread" 的错误信息。本文将详细介绍该错误的解决方案。 错误原因 "No Hibernate Session bound to thread" 错误信息通常是...

    branch and bound

    对于序列版本的B&B算法,有几个关键点需要注意: 1. **边界函数的选择**:选择合适的边界函数对于剪枝策略至关重要。 2. **初始解的质量**:一个好的初始解可以极大地提高搜索效率。 3. **分支规则的设计**:高效的...

    lower-bound函数1.zip

    需要注意的是,`lower_bound`的前提条件是输入的序列必须是有序的。如果序列无序,其结果可能不正确。同时,如果需要查找的元素不存在于序列中,返回的迭代器会指向序列末尾,而不是插入点。如果需要找到插入点,...

    lower-bound函数应用案例.zip

    在C++标准库中,`lower_bound`是一个非常重要的算法,它属于`<algorithm>`头文件。`lower_bound`函数通常用于排序好的容器(如数组或向量)中,找到给定值的第一个大于或等于该值的元素的位置。这个位置被称为“下界...

    lower-bound 的简要介绍.docx

    #### 五、注意事项 1. **前提条件**:使用 `lower_bound` 之前,必须确保传入的序列是有序的。如果序列无序,则可能会导致错误的结果。 2. **比较规则**: - 第一个版本基于 `操作符,默认按照升序排列。 - 第二...

    Error Correction coding——mathematical methods and algorithms

    1 S.5 Bounds on Performance: The Union Bound . . . . . . . . . . . . . 22 1.5.6 The Binary Symmetric Channel . . . . . . . . . . . . . . . . . . . 23 1 S.7 The BSC and the Gaussian Channel Model . . ....

    MATLAB.zip_Branch and bound_branch bound_分支定界_分支定界matlab_分支定界法

    MATLAB分支定界法求解,大家

    举例让你明白lower-bound函数

    需要注意的是,`lower_bound`和`upper_bound`函数都需要输入的序列是有序的,否则结果可能不正确。在使用这些函数之前,确保对容器进行排序是必要的。 总结来说,C++中的`lower_bound`函数是一个强大且高效的工具,...

Global site tag (gtag.js) - Google Analytics