10 Things flex developers need to know

Source: Internet
Author: User
ArticleDirectory
    • 1. Simple things are asynchronous.
    • 2. Understand the style and attributes of the Flex component
    • 3. The style in Flex is different from that in HTML.
    • 4. Although it looks different, mxml and ActionScript are essentially the same thing.
    • 5. Understand the code-behind mode of flex
    • 6. Understand the lifecycle of flex Components
    • 7. Understand the "Runway" model used when Flash is running.
    • 8. Understand Data Binding and viewer (watcher)
    • 9. Data encapsulation and loose coupling are very important
    • 10. Understand weak references and strong references in ActionScript

Not long ago, Michael portuesi published a blog post about 10 Things flex developers need to know. This article introduces the basic knowledge and skills that every developer who enters the flex field must possess.

Among the 10 entries given by Michael portuesi, some are simple details that developers need to know, and some reveal the differences between Flash/ActionScript/flex and other development environments.

If you understand HTML/CSS and are familiar with JavaScript, but do not know anything about ActionScript or flex, you should take some time to learn object-oriented programming, because ActionScript is a completely object-orientedProgramming LanguageAnd flex is an object-oriented framework.

1. Simple things are asynchronous.

Flex is an asynchronous framework, so we absolutely cannot expectCodeIt can be executed immediately after the call. In fact, we cannot predict the call sequence of methods.

2. Understand the style and attributes of the Flex component

Flex UI components (buttons, menus, and so on) have both attributes (specified by the ActionScript language) and styles (specified by the flex framework ). It is very important to understand the differences between them, because some visualization effects of components can be specified through attributes, but others can only be set through styles. Specify through attributes:

 
Button. width = 100; button. Height = 50;

Specify by style:

 
<Mx: style> button {color: # cc0000; textrolovercolor: # ccff00; fontfamily: trebuchet MS;} </MX: style> <mx: button id = "setupb" text = "Click me" Click = "onsetup ()"/>
3. The style in Flex is different from that in HTML.

You can use a standard CSS style sheet to add a style for the flex component, or include a CSS style sheet in the flex application. Although the standard CSS uses a hyphen (for example, text-font) format to define style names, flex uses a camper format (for example, textfont ). This is because a hyphen cannot appear in XML attributes, so such a name cannot be used as the attribute of the mxml tag.

Of course, if you define a style in an external CSS file or style label, you can also use a style name in the hyphen format. In addition, flex defines many CSS styles that do not exist in HTML.

4. Although it looks different, mxml and ActionScript are essentially the same thing.

All mxml labels declared in FLEX will be converted to ActionScript code by the flex compiler. Of course, you can also embed inline ActionScript code in the mxml file. You can use mxml or ActionScript to create a new component.

5. Understand the code-behind mode of flex

Although mxml and ActionScript are essentially the same, they perform their respective duties. Generally, mxml is used to display the interface, while ActionScript is used to complete the function. Code-behind is used to decouple mxml and ActionScript, so that the designer can directly modify mxml without reading the code,ProgramPersonnel can better organize and reuse functions.

6. Understand the lifecycle of flex Components

Flex defines a perfect life cycle model through the state machine mechanism for component creation, operation, and destruction. It also defines some "portals" for developers to complete customization. Failing to fully understand the life cycle of components may lead to incorrect programming models.

7. Understand the "Runway" model used when Flash is running.

It is very important to understand the rendering and code execution mechanisms of Flash Player. When you execute the command to change the UI, flash player does not immediately display the content you want on the screen. It refreshes the screen according to a certain period of time, code execution is another matter. This is the opposite of Java. Java always waits for the program to actively tell it when to repaint the screen.

8. Understand Data Binding and viewer (watcher)

Flex provides a data binding mechanism. Simply put, a source attribute is bound to a target attribute. When the source attribute changes, the target attribute also changes. Not only can attributes be bound, but can also be bound to functions. You can even create a watcher for a property and receive event notifications when the property changes.

9. Data encapsulation and loose coupling are very important

Code Organization and high-level structure are important for flex and air projects. Some people write more than 1000 lines of code in a single file, which leads to the problem of getting started.

10. Understand weak references and strong references in ActionScript

regardless of the language used and development environment, memory management is always an important issue, and ActionScript is no exception. If you do not understand the memory management in the runtime environment, memory leakage and memory fragmentation may easily occur. Read this blog post and article to learn more about the garbage collection mechanism of ActionScript.

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.