开发者

How to declare a function to be equal to another function in as3?

开发者 https://www.devze.com 2023-04-11 19:09 出处:网络
If I wanted to create a function called printMe, what\'s the proper syntax so that it开发者_高级运维 prints what the function information prints?

If I wanted to create a function called printMe, what's the proper syntax so that it开发者_高级运维 prints what the function information prints?

var named:String="me";
var age:int=100;



function information():void{
    trace(named, age);
}

information();

I tried a few things like

printMe=information;
printMe();

Here are the errors I'm getting

Scene 1, Layer 'Layer 1', Frame 1, Line 8 1120: Access of undefined property printMe.

Scene 1, Layer 'Layer 1', Frame 1, Line 9 1180: Call to a possibly undefined method printMe.


Try

var printMe:Function = information;
printMe();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号