Like any normal ActionScript object, applications have to be instanced before they can be used. This is an important concept when using the Flash Communication Server. In Chapter 10, "STEP 10: Lobby Applications," you saw instancing in action, with the RoomList component. SSAS within the main.asc file is compiled each time a new instance of the application is run. You create instances using the NetConnection.connect ActionScript in either the Flash player or SSAS. As you saw earlier, you can also manually create an instance using the App Inspector. Each Application instance operates within its own context. Users connected to instances of an application cannot access other instances without closing the current connection and opening another connection (see Figure 11.1). This is an extremely important security feature with the Flash Communication Server.
Figure 11.1 The Application instance makes a copy of the Application object. Instances have no relationship with each other without a NetConnection bridge.
Applications have a scope that can be used by all clients connected to a single Application instance. The application scope does not include other instances. Methods, properties, and events can be created to handle when an instance starts and when users can connect. You saw this when the Application.onConnect event was created to handle a Flash player connecting.
The Application instance is defined as a collection of stream objects, SharedObjects, and (connected Flash) clients. Each application and instance must have a unique name that must adhere to the Uniform Resource Identifier (URI) convention.