Notes
First, the parameters of the function in AS3 can have a default value.
Public Function TestFunc () {
MyFunc ();
}
Private Function MyFunc (para1:int=10,para2:string= "str"): void{
Trace (Para1 + "," + para2); Ten, str
}
No extra parameters can be given in the AS3.
Public Function TestFunc () {
MyFunc (2, "3", 4);
}
Private Function MyFunc (para1:int,para2:string): void{
Trace (Para1 + "," + para2);
}
The compiler gave a parameter mismatch error: Argumenterror:error #1063: Argument count mismatch on Testfunc/testfunc::myfunc (). Expected 2, got 3.
So the previous method of using arguments to get the invariant parameters can not be used. AS3 gives a new keyword: ... (rest) parameter
Public Function TestFunc () {
MyFunc (2, "3", 4, "5", true);
}
Private Function MyFunc (para1:int,para2:string,... more): void{
Trace (Para1 + "," + para2); 2, 3
Trace (more); 4,5,true
}
After a fixed parameter followed by a "..." and an expression (such as "more" in the example), "..." All subsequent arguments are placed in the array named by the expression. Note "..." Must be the last parameter.
If you use the "..." arguments, you will not be able to get Arguments.callee (a reference to the currently executing function), so you can use "..." when you are certain that you are not using callee.
Referring to arguments, Arguments.caller has been "removed". To get caller, you need to pass the call function's callee as an argument to the called function. The official example:
Package {
Import Flash.display.Sprite;
public class Argumentsexample extends Sprite {
private var count:int = 1;
Public Function Argumentsexample () {
Firstfunction (TRUE);
}
Public Function Firstfunction (Callsecond:boolean) {
Trace (Count + ": firstfunction");
if (Callsecond) {
Secondfunction (Arguments.callee);
}
else {
Trace ("CALLS STOPPED");
}
}
Public Function Secondfunction (caller:function) {
Trace (Count + ": secondfunction\n");
count++;
Caller (false);
}
}
}
Small series of words: Or that sentence, we are not everyone can understand the flex so, but each of us can do a little bit of interest for our efforts. As long as your one click, a message can give the author more power. International...... Collective to fool the nest of the words of irrigation.