Detailed description of MVC usage in Flash AS3

Source: Internet
Author: User

The functions of the data layer:

1. Encapsulates the function of communicating with the server, providing a call () interface for external (one view) calls to complete the function of sending data to the server

2. Process and resolve data returned by the server. For example, after the server returned data, a function is called in data, this function according to the protocol to read the function of the packet, read the data to fill in their own instance variables

3. Provide the Listening interface path (protocol, callback function), let the external (generally view), listen to the protocol concerned, once the server returns to this protocol, the callback function will be executed.

View Features:
1. Controlling the UI, responding to user interaction
2. Call the Data.path method to listen for data change events of your own concern
3. Once the user clicks on (or other events): A. It is possible to send data to the server. Once the server returns the data, the callback function is executed and the corresponding Ui;b is changed. Call the other view's interface and communicate with it

1:model: The model is the core of the entire application. Because it saves all the data for the application and processes the business process. The so-called business process, is the operation of the application data, such as additions and deletions to check, if necessary, and the server communication. The operation of the data is black-box operation, hiding the details and providing only the interface. To ensure the uniqueness of data, integrity. So, you can't write code that changes the model data in the view, because there are multiple views, a view that changes the data, and another view may not know, causing the data to be not unique. The model is designed to be right, then you assume that if you want to transfer your current to the project to other platforms (such as page migration to the mobile platform), your model is not a code without change, a code also need not increase?

2.view: The function is to manage its own UI and work with other view coordinates. Managing its own UI includes, a. Accept and influence the user's operations, collect data, and pass it on to Model,b. Listen for changes in model to change yourself. The UI is a sprite or movieclip,ui should not know MVC (that is, it will not invoke the MVC-related code, do not know model), it only provides the interface to view to invoke management. The advantage of this is that the UI can be reused, for example, if you change an MVC framework, the UI code can be used directly without modifying a row.

3.controller: It can be understood that the user receives the request, matches the model to the view, completes the user's request, but does not do any data processing. Personally understand that when a data corresponds to a number of views, it is useful, otherwise it seems a bit redundant. However, some of the MVC framework does not understand it, such as PureMVC's controller has a exec method, it is not a simple "to match the model with the view"

And finally, Vo/info, it's the internal structure of a type of data that the UI can reference directly

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: 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.