ActionScript 3 作用域内部细节介绍
ActionScript 3 的作用域使用對象鏈表來記錄在作用域中的定義(變量、函數(shù)、類、接口和命名空間)。
● Class scope: the class's Class object (and the Class objects of the class's ancestors)
●?Static method scope: the class's Class object (and the Class objects of the class's ancestors)
●?Instance method scope: the current object (i.e., this) and an activation object (an "activation object" is an object created and stored internally by ActionScript for the purpose of maintaining the local variables and parameters of function or method)
●?Function scope: an activation object
如下樣例代碼:
1 package { 2 public class SomeClass { 3 public function instanceMeth():void { 4 function nestedFunc():void { 5 trace(a); 6 } 7 } 8 } 9 } 10 var a:int = 15;?
它的搜索過程為:
1、newstedFunc() 的 activation object
2、調(diào)用 instanceMeth() 的對象
3、SomeClass 的類對象
4、Object 的類對象(在搜索全局對象之前,它會先搜索 SomeClass 的父類,也就是 Object 的類)
5、全局對象
轉(zhuǎn)載于:https://www.cnblogs.com/ezine/archive/2012/06/10/2544070.html
總結(jié)
以上是生活随笔為你收集整理的ActionScript 3 作用域内部细节介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【算法刷题3】二叉树的最大深度
- 下一篇: 性能面试题目