O'Reilly logo

ActionScript 3.0 Design Patterns by Chandima Cumaranatunge, William Sanders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Communication Between the MVC elements

Each element in the MVC pattern communicates with each other in very specific ways. Communication is necessitated by a sequence of events that are generally triggered by a user interacting with the application. The sequence of events is represented as follows:

  1. User interacts with a user interface element (e.g. clicks on a button in a view).

  2. The view sends the click event to the controller to decide how to handle it.

  3. The controller changes the model based on how it decides to handle the button click.

  4. The model informs the view that the state of the model has now changed.

  5. The view reads state information from the model and updates itself.

Figure 12-1 shows the graphical representation of the channels of communication between MVC elements. The arrows' directions show the direction of communication.

Direction of communication between MVC elements

Figure 12-1. Direction of communication between MVC elements

This is a very simple model of how MVC elements communicate. In some cases the controller can directly tell the view to make changes as well. This is the case only when the changes in the view necessitated by user action don't require a change in the model itself, but simply a change in visuals. For example, think about the process whereby a user selects a song to play in our portable digital music player. The user selects songs from a list using buttons that scroll the list. The view would tell the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required