# Define functions

**URL:** https://forum.kirupa.com/t/define-functions/184126
**Category:** Uncategorized
**Created:** [April 2, 2006, 12:49pm UTC](https://forum.kirupa.com/t/define-functions/184126 "2006-04-02T12:49:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![g5604](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@g5604](https://forum.kirupa.com/u/g5604)
#### Post date: [April 2, 2006, 12:49pm UTC](https://forum.kirupa.com/t/define-functions/184126/1 "2006-04-02T12:49:48Z")

</div>

Hi,

i noticed that there are two ways to define functions:

```php
function hello () {
// do something
} 

```

```php
hello = function () {
// do something
}

```

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

---

<div class="post-metadata">

### Author: ![NinoScript](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ninoscript/32/1484_2.png) [@NinoScript](https://forum.kirupa.com/u/NinoScript)
#### Post date: [April 2, 2006, 2:06pm UTC](https://forum.kirupa.com/t/define-functions/184126/2 "2006-04-02T14:06:41Z")

</div>

nope, it doesn’t matter 🙂

although i usually define them like this:

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

```

---

<div class="post-metadata">

### Author: ![g5604](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@g5604](https://forum.kirupa.com/u/g5604)
#### Post date: [April 2, 2006, 3:20pm UTC](https://forum.kirupa.com/t/define-functions/184126/3 "2006-04-02T15:20:13Z")

</div>

intresting… thanks!

---

<div class="post-metadata">

### Author: ![devonair](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@devonair](https://forum.kirupa.com/u/devonair)
#### Post date: [April 2, 2006, 3:30pm UTC](https://forum.kirupa.com/t/define-functions/184126/4 "2006-04-02T15:30:29Z")

</div>

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](http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001670.html)

---

<div class="post-metadata">

### Author: ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)
#### Post date: [April 2, 2006, 9:17pm UTC](https://forum.kirupa.com/t/define-functions/184126/5 "2006-04-02T21:17:26Z")

</div>

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

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

:disco:

---

<div class="post-metadata">

### Author: ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)
#### Post date: [April 2, 2006, 10:03pm UTC](https://forum.kirupa.com/t/define-functions/184126/6 "2006-04-02T22:03:48Z")

</div>

i prefer,

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