Home > Actionscript 3, Flash > Actionscript 3 – arguments of each function

Actionscript 3 – arguments of each function

An arguments object is used to store and access a function’s arguments. Within a function’s body, you can access its arguments object by using the local arguments variable. The arguments are stored as array elements: the first is accessed as arguments[0], the second as arguments[1], and so on. The arguments.length property indicates the number of arguments passed to the function. There may be a different number of arguments passed than the function declares.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package {
    import flash.display.Sprite;
 
    public class ArgumentsExample extends Sprite {
        public function ArgumentsExample() {
                println("Hello World");
        }
 
        public function println(str:String):void {
            trace(arguments.callee == this.println); // true
            trace(arguments.length);                 // 1
            trace(arguments[0]);                     // Hello World
            trace(str);                                // Hello World
        }
    }
}
Categories: Actionscript 3, Flash Tags:
  1. No comments yet.

Spam Protection by WP-SpamFree

Get Adobe Flash playerPlugin by wpburn.com wordpress themes