Flash
  Home arrow Flash arrow Page 2 - Using Function: The Beginner's Nightmare
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Using Function: The Beginner's Nightmare
By: Aleksandar Horvat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    2004-10-27

    Table of Contents:
  • Using Function: The Beginner's Nightmare
  • Function statement
  • Do you like functions?
  • More on reusability: practical example
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using Function: The Beginner's Nightmare - Function statement


    (Page 2 of 5 )

    Since this article is not about every variants of practical using of functions, I will touch only the foundation. What are the functions? Here is a simple introduction. In flash Actionscript function comes in a simple syntax:

    function myFirstFunction(param  ,param  2, …,param n){
    set_of_statements;
    }

    Function declarations start with keyword 'function', followed by function name and the set of parameters, if any, to be passed to function. You can also setup a function without required parameters; it could be invoked without them.

    We can invoke the function by simply using its name as a statement and providing parameters as necessary.

    myFirstFunction(param 1, param 2,..., param n);

    The number of parameters is up to you. After executing the function, your program will return to the program line right after the line that invokes the function. Let’s see the practical example:

    //**set up the function that will add two numbers:
    function sum_number(num1, num2){
    result=num1+num2;
    trace("The result is " add result);
    }

    To use that function, we will invoke it like this:

    sum_number(2, 6);

    The output window will show:

    The result is 8

    This is just the simple example. Functions can be more complex and can contain all kind of actions, calculations and other creative solutions.

    You can easily use functions to organize and modularize your code flow. While building an application, you can use functions to simplify your work by placing function on some central place, for example, the main timeline.

    Functions have many different aspects of use. They can easily be nested one within another; they can use them as prototypes to define new methods and properties for the objects etc.

    More Flash Articles
    More By Aleksandar Horvat


       · This is the most basic of introductions. S/he could have been more instructive if...
     

    FLASH ARTICLES

    - Critical Flash Vulnerability Heats Up the Web
    - More on Nonpersistent Client-Side Remote Sha...
    - Nonpersistent Client-Side Remote Shared Obje...
    - Using the Decorator Pattern for a Real Web S...
    - Using Concrete Decorator Classes
    - Delving More Deeply into the Decorator Patte...
    - The Decorator Pattern in Action
    - A Simple Decorator Pattern Example
    - Decorator Pattern
    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek