If you look at First Steps I you might notice, that we use import to get holde of the flash.util.trace function. In Actionscript 2 we only could import classes. Is trace a class now?
The short answer is no. The long answer is, the new package concept of Actionscript 3 allows for defining functions as members of a package. These package members can be imported just like classes. Even package variables are possible. Here is a little example
//在AS3中允许你将函数当一个成员作包中(不必写在CLASS里面)
Cheers,
Ralf
/////////////////
因为是个人读书的笔记,所以没有进行翻译,只是对其中关键地方进行注释。如有错误欢迎指出。
原文转载自: www.helpqlodhelp.com/blog/
The short answer is no. The long answer is, the new package concept of Actionscript 3 allows for defining functions as members of a package. These package members can be imported just like classes. Even package variables are possible. Here is a little example
//在AS3中允许你将函数当一个成员作包中(不必写在CLASS里面)
package { import flash.util.trace; import flash.display.MovieClip; public var surname:String = "Mueller"; public function willi(){ trace("willi " + surname + " was here"); } public class Test1 extends MovieClip { public function Test1() { willi(); } } }
Cheers,
Ralf
/////////////////
因为是个人读书的笔记,所以没有进行翻译,只是对其中关键地方进行注释。如有错误欢迎指出。
原文转载自: www.helpqlodhelp.com/blog/
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}