# Custom functions: Default values?

**URL:** <https://forum.kirupa.com/t/custom-functions-default-values/170387>\
**Category:** flash\
**Created:** [November 25, 2005, 10:02am UTC](https://forum.kirupa.com/t/custom-functions-default-values/170387 "2005-11-25T10:02:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CEOofAEP](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@CEOofAEP](https://forum.kirupa.com/u/CEOofAEP)\
**Post date:** [November 25, 2005, 10:02am UTC](https://forum.kirupa.com/t/custom-functions-default-values/170387/1 "2005-11-25T10:02:29Z")

</div>

Dear diary,

okay- so I was really just wondering, if there is something like setting default values for a “tailor made” function that accepts variables? I mean- PHP offers the

```php
function mycoolphpfunction ($myvar = "my default value") {
	return $myvar;
}

```

…in case you’re not familiar with PHP: if no value is given to “mycoolphpfunction”, it just returns (in this case) “my default value”.

Does Actionscript have something similar? I didn’t find any reference to it so I’m just using…[AS]function mycoolasfunction (myvar) {  
if ((myvar == undefined) || (myvar == “”)) {  
myvar = “my default value”;  
}  
}[/AS]…to achieve the same effect.

Any way how I could save myself some time in any way? I guess instead of the “((myvar == undefined) || (myvar == “”))”-check, I could just write another function that checks a value / variable- if it is filled, it returns the value it’s filled with, if it isn’t filled, it returns the second value. I’ll experiemnt on that 🙂

Thanks in advance- and for your time reading this! 🙂

~Me
