Functions
What are functions?
Functions allow the user to manipulate the code as they see fit.
Functions can be triggered whenever the user wishes to, enabling them to have multiple purposes.
A function is built pretty simply.
First you start off by writing the word "function" followed by the name of the function it is calling. After that you would input any links or needed input within brackets.
So far the function would look like this.
function myFunc (input)
Now we have labeled the function it is time to add its commands.
Most functions dont return any information and because As3 is mostly strict type for speed purposes. If the function returns no data you need to put ":void" at its end like so.
function myFunc (input):void
To tell a function what its command is you need to place its comand within curly bracets like so.
function myFunc (input):void{
//comands
}
And that is that.
One more thing, "input" is just there to show that it can contain data, if you have no input then it should be blank like this.
function myFunc ():void{
//commands
}
Examples of functions to follow.
How do you use a function?
Functions can be used anywhere within your code be that in an event listener or an if function.
To trigger your function all you need to put is the functions name and the input value, if it is needed.
myFunc();