Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Concept of Functions in ActionScript3

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.58k
    Comment on it

    Functions are very useful part of ActionScript3 as they save the time, reduce the code and also increases the re-usability of the code. Function is that block or piece of code which can be used reused at any point in the code. They save the time as they can be called any number of times when required.

    Calling the Functions
    The calling of the function is done by using the parentheses operator.For Example the use of TRACE( ) function is shown below:

    trace( " USED FOR DEBUGGING THE SCRIPT ");
    

    Incase you are calling a function with no parameters in it then in that case empty pair of parentheses should be used.For Example

    var random:Number = Math.random();
    

    Defining Your Own Function

    In ActionScript3 there are two ways of defining the functions.

    1. Function Statement
    2. Function Expression


    1. FUNCTION STATEMENT :The function statements are used if you want to define your functions static or stricted. A function statement starts with the function keyword. The following is the syntax for the function statement :-


    function traceParameter(aParam:String) 
    { 
        trace(aParam); 
    } 
    
    traceParameter("hello"); // hello
    


    2. FUNCTION EXPRESSION: The function expressions are used to when you have to define more dynamic or standard programming. Function expression were used in the earlier versions of the ActionScript. The Syntax for this is as follows:-


    var traceParameter:Function = function (aParam:String) 
    { 
        trace(aParam); 
    }; 
    traceParameter("hello"); // hello
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: