Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Part II: Patterns > State Pattern

Chapter 12. State Pattern

In This Chapter

Simple State Example 181

Encapsulating the States 184

Using Abstract Classes 188

Transitions 193

Summary 198

The State pattern is a valuable pattern in ActionScript development. It allows an object to change its behavior when its internal state changes. Take a toggle button as an example. The toggle button must maintain two separate states: one for selected and one for unselected. The two states share the same structure, but they have very different functionality. In addition to the visual display being different, they most likely handle a click event differently, too. This is where the State pattern becomes valuable. The State pattern defines a standard methodology for handling encapsulated states.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial