There are also embedded methods in ActionScript 3, which should be embedded functions. Let's take a look at the specific example: Package
...{
Import flash. display. Sprite;
Public class nestedfunction extends Sprite
...{
Public Function nestedfunction ()
...{
Trace (add (1, 2 ));
}
Private function add (X: int, Y: INT): int ...{
Return addaliass (x, y );
Function addaliass (X: int, Y: INT): int ...{
Return X + Y;
}
}
}
}
This writing method is a typical modular design (the shadow of as2). It may be more flexible to use embedded functions in some small modules. Otherwise, there will be too many class methods to write all functions, but on the other hand, this is not conducive to code reuse after writing, and embedded functions cannot be called outside the class. weigh the advantages and disadvantages and you can only look at the specific situation.