Flex3 Study Notes 3

Source: Internet
Author: User
Flex3 Study Notes 3

Flex script Basics

1) Method
The concept is simple, because the basic function is the method. The method is a function in the class. For example, you can register an event listener with applicationcomplete events. Add the following attributes to the application Tag:

  1. Applicationcomplete = "fullnametextinput. setfocus ()"

2) Variable
A variable is a method for storing information in a program. For example:

  1. VaR username;
  2. Username = "Tom ";
  3. VaR username = "Tom ";
  4. Public var username = "Tom ";

3) Data Type
Basic data types include:
String string
Number value. The default value is Nan (not a number ")
Uint unsigned integer; default value: 0
Int integer. The default value is 0.
Boolean value. The default value is false.
Void is used as a special value of the function, indicating that no response is returned. The default value is undefined.
For example:

  1. Public Function dosomemath (): number {
  2. Return 2 + 2;
  3. }

4) object
Everything is an object. ActionScript is an object-oriented language. To some extent, an object is a container. It has some attributes (states) and some operations (Actions) on the attributes ). As follows:

  1. VaR car: Object = new object ();
  2. Car. type = "sports car ";
  3. Car. color = "red ";
  4. Car. topspeed = 170;
  5. Car. isinsured = false;
  6. Car. Driver = undefined;
  7. VaR person: Object = new object ();
  8. Person. Name = "Steve ";
  9. Person. Age = 19;
  10. Car. Driver = person;

5) Class
The object is a class instance. If you have a car object and you want to create another car object, that is, you have to do the same thing. What should you do? The best way is to create a car class and instantiate it twice to generate two car objects respectively. For example:

  1. Public class car {
  2. VaR type: string;
  3. VaR color: uint;
  4. VaR topspeed: int;
  5. VaR isinsured: Boolean;
  6. VaR DRIVER: person;
  7. }
  8. Public class person {
  9. VaR name: string;
  10. VaR age: int;
  11. }
  12. VaR car: Car = new car ();
  13. Car. type = "sports car ";
  14. Car. Color = 0xff0000;
  15. Car. topspeed = 170;
  16. Car. isinsured = false;
  17. Car. Driver = undefined;
  18. VaR person: person = new person ();
  19. Person. Name = "Steve ";
  20. Person. Age = 19;
  21. Car. Driver = person;

6) mxml and ActionScript
Mxml cannot replace ActionScript. mxml and ActionScript complement each other. Scripts are quite useful in terms of interactivity. In fact, mxml can be used to build a complete application only by using pure ActionScript. However, using mxml to create an application structure is the best method because it is easy to read and write.

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.