as3 arguments.callee与... (rest)
import flash.display.Sprite; var count:int = 1;
ArgumentsExample()
function ArgumentsExample()
{
firstFunction();
} function firstFunction()
{
trace(count + ": firstFunction"); secondFunction(arguments.callee); } function secondFunction(caller:Function)
{
trace(count + ": secondFunction\n");
count++;
if(count<3)
caller();
}
输出:
1: firstFunction
1: secondFunction
2: firstFunction
2: secondFunction
以上代码演示如何获得对函数的引用,该函数调用名为 secondFunction() 的函数。
官方解释:
用于存储和访问函数参数的参数对象。在一个函数体内,可以使用局部参数变量来访问其参数对象。
这些参数存储为数组元素:第一个存取为 arguments[0],第二个存取为 arguments[1],依此类推。arguments.length 属性表示传递给函数的参数数目。传递的参数数目可能与函数声明的数目有所不同。
与以前版本的 ActionScript 不同,ActionScript 3.0 中不包含 arguments.caller 属性。要获得对调用当前函数的函数的引用,必须将一个引用作为参数传递给该函数。可从 arguments.callee 示例中找到该技术的示例。
针对:要获得对调用当前函数的函数的引用,必须将一个引用作为参数传递给该函数。这句话。理解不透
... (rest) parameter 定义关键字 用法
function functionName(parameter0, parameter1, ...rest){
// statement(s)
}
... (rest)与arguments用法差不多。不过没有arguments的callee方法。
as3 arguments.callee与... (rest)的更多相关文章
- AS3在函数内部移除监听(arguments.callee)
scene.addEventListener(Event.ADDED_TO_STAGE, function():void { scene.removeEventListener(Event.ADDED ...
- JavaScript Arguments.callee解释
Arguments.callee : 返回正被执行的 Function 对象,也就是所指定的 Function 对象的正文.[function.]arguments.callee可选项 functio ...
- 搞清arguments,callee,caller
arguments是什么? arguments是函数调用时,创建的一个类似的数组但又不是数组的对象,并且它存储的是实际传递给函数的参数,并不局限于函数声明的参数列表哦. 尼玛,什么意思? 写个demo ...
- arguments.callee的用法
argument为函数内部对象,包含传入函数的所有参数,arguments.callee代表函数名,多用于递归调用,防止函数执行与函数名紧紧耦合的现象,对于没有函数名的匿名函数也非常起作用.举例如下: ...
- JavaScript中的arguments,callee,caller
在提到上述的概念之前,首先想说说javascript中函数的隐含参数: arguments: arguments 该对象代表正在执行的函数和调用它的函数的参数. [function.]argument ...
- click 事件 arguments.callee 每次点击自动* 2
今天在测试JQUERY(版本3.0,向下兼容3.0)时发现一个很特别的现象,代码如下: $($('button').get(4)).click(function(){ alert($(this).ht ...
- arguments.callee 调用自身 caller,callee,apply and call
一.Arguments该对象代表正在执行的函数和调用他的函数的参数.[function.]arguments[n]参数function :选项.当前正在执行的 Function 对象的名字.n :选项 ...
- 理解JavaScript中的arguments,callee,caller,apply
arguments 该对象代表正在执行的函数和调用它的函数的参数. [function.]arguments[n] 参数function :选项.当前正在执行的 Function 对象的名字. n : ...
- js的隐含参数(arguments,callee,caller)使用方法
在提到上述的概念之前,首先想说说javascript中函数的隐含参数: arguments arguments 该对象代表正在执行的函数和调用它的函数的参数.[function.]arguments[ ...
随机推荐
- hasura 的3factor 架构结论
hasura 是一个很不错的开发团队,开发了好几款,不错的产品,最近的graphql engine 是很热的一款 graphql 引擎,同时团队提出了3factor 系统架构理论 参考网站 https ...
- python安装途中遇到的问题和解决方法
一.setuptools安装错误:RuntimeError: Compression requires the (missing) zlib module 1. 描述 搞了个腾讯云的服务器,闲在手上没 ...
- ThinkPHP 5 中的 composer.json
本篇并不是揭 ThinkPHP 5 的问题. 只是通过 composer.json 来学习 compoer.json 元旦那天, ThinkPHP 5.1 正式发布,值得庆祝. 之后的第二天有人反馈 ...
- websocket小体验
http://www.cnblogs.com/GoodHelper/p/7078381.html https://segmentfault.com/a/1190000012084213
- FineUI 3升级4.1.1时,SingleClickExpand属性改什么了? (树控件单击展开)
private Tree InitTreeMenu(List<Menu> menus) { Tree treeMenu = new Tree(); treeMenu.ID = " ...
- FineUI中在一个页面中通过控件事件(JS)向父页面中添加Tab页
1.在前台页面尾部添加js代码 </form> <script type="text/javascript"> var basePath ...
- 启动servlet报错:The servlets named [DemoServlet] and [main.java.com.wlf.demo.servlet.DemoServlet] are both mapped to the url-pattern [/hello] which is not permitted
先看具体错误日志: [2019-04-26 09:29:25,484] Artifact demo-servlet:war: Artifact is being deployed, please wa ...
- jquery tmpl学习资料 --{{each}} each使用
<!DOCTYPE html><html><head> <script src="Scripts/jquery-1.6.2.min.js&qu ...
- dede的织梦问答模块也可以支持arclist标签
dedecms织梦问答等模块支持arclist标签,实现随机调用其他栏目文章 就是让模块模板文件支持调用主站的模板,因为调用主站下的/templets/default/模板,也就实现了支持调用所有标签 ...
- android onSaveInstanceState()及其配对方法。
转自:http://blog.chinaunix.net/uid-22985736-id-2977672.html onSaveInstanceState() 和 onRestoreInstanceS ...