Define functions

Hi,

i noticed that there are two ways to define functions:

function hello () {
// do something
} 

hello = function () {
// do something
}

which one should i use? or does it not really matter.

nope, it doesn’t matter :slight_smile:

although i usually define them like this:

var hello:Function = function () {
trace("hello everybody!");
};

intresting… thanks!

If you’re bored, you can check out the help file or livedocs - it recommends the
[AS]function myFunc(arg:Type):ReturnType{
//…
}[/AS]
syntax inside of class files…

http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001670.html

function hello(){} can be called before its definition in the script.

hello = function(){} can be created in the scope of another object.

:disco:

i prefer,

function hello():Void{
trace(“Hello World!”);
}