as3fornubies2's profile picture.

ActionScript 3.0

@as3fornubies2

One apparent exception is if-else conditional statement, even though if you look closer you will see that it doesn't actually violate rule.


You cannot place any code after the line that contains return statement. Soing so will generate a runtime error.


Type of data, as always, shoudl be declared.


Functions can return any data types, from simple like boolean, numbers or stroongs, to complex like Arraysm objects, or even custom classes.


var copyright:String = getCopyrightDate();


For example, if a function cakked getCopyrightDate returns the string with the date, you would call it like this:


You will then need to call the function as the value of the variable.


It's easy to achieve: as the last line of the function, write retuen followed by the variable to be sent out of the function.


You can accomplish this task by having a function retun a value.


Often you will ned a function to perform a task and create some variable that needs to be used by the remainder of your script.


It is possible to also pass arguments by named references.


So the arguments could be literal values, variables, or instances of objects (!).


You should declare the data type of each argument, and be sure that the data assed tothe function is of the right type.


You pass arguments in the parentheses in the signature line, and then use them as variabkles through the function.


If you need to manipulate a variable from outside the script, pass that variable directly to the function in the form of an argument.


Instead, write the code in such a way that functions onlyu ever work with their own data.


However, you shouldn't have the function to directly manipulate an external variable. It's confusing.


Variables outside of functions are global, and can be accessed from anywhere - both from inside or outside of the functions.


Variables created within a function are local to that function. The rest of the script cannot read them.


Instead, separate the tasks.


This account does not follow anyone
Loading...

Something went wrong.


Something went wrong.