ActionScript 3.0 Design Patterns

(Chris Devlin) #1

382 | Chapter 10: State Pattern


Figure 10-6 shows what your video player should look like.


Adding More States and Streaming Capabilities


Now that the structure can support a simple FLV playback system, the next step will


be to add two additional states and see if the state machine can be adapted to a Flash


Media Server application. Keeping the focus on the design pattern, only two new


states will be added—Record and Append.


Changing from a Flash application to a Flash Media Server 2 (FMS2) application


requires key changes in the FLA script to include a connection to the server, and add-


ing Camera and Microphone objects. Otherwise, you’ll find that adding the addi-


tional states of Record and Append are relatively simple.


Setting Up Your ActionScript 3.0 Script for FMS2


Adding states is relatively easy, as you’ve seen. However, when you add Flash Media


Server 2, you need to take care of a few matters to make sure that your application


works correctly. Because AS 3.0 and Client-Side ActionScript (CSAS) used in FMS2


are a bit different, you need to import thenet.ObjectEncodingclass. By doing so,


Figure 10-6. Player with added Pause button

Free download pdf