Embedded Method in ActionScript 3

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.