SharedObject 클래스는 사용자의 컴퓨터 또는 서버에서 제한된 양의 데이터를 읽고 저장하는 데 사용됩니다. 공유 객체는 로컬 컴퓨터 또는 원격 서버에 영구적으로 저장되는 여러 클라이언트 SWF 파일과 객체 사이의 실시간 데이터 공유를 제공합니다. 로컬 공유 객체는 브라우저 쿠키와 비슷하며, 원격 공유 객체는 실시간 데이터 전송 장치와 비슷합니다. 원격 공유 객체를 사용하려면 Adobe Flash Media Server가 필요합니다.

The SharedObject class is used to read and store limited amounts of data on a user's computer or on a server. Shared objects offer real-time data sharing between multiple client SWF files and objects that are persistent on the local computer or remote server. Local shared objects are similar to browser cookies and remote shared objects are similar to real-time data transfer devices. To use remote shared objects, you need Adobe Flash Media Server.

 

다음과 같은 경우 공유 객체를 사용하십시오.

Use shared objects to do the following:

 

  • 로컬 지속성을 유지합니다. 이것은 공유 객체를 사용하는 가장 간단한 방법이며 Flash Media Server가 필요하지 않습니다. 예를 들어 SharedObject.getLocal()을 호출하여 응용 프로그램에서 공유 객체(예: 메모리 있는 계산기)를 만들 수 있습니다. 사용자가 계산기를 닫으면 Flash Player는 마지막 값을 사용자 컴퓨터의 공유 객체에 저장합니다. 다음에 계산기가 실행되면 이전의 값을 포함하고 있습니다. 또는 계산기 응용 프로그램을 닫기 전에 공유 객체의 속성을 null로 설정했다면, 다음에 이 응용 프로그램을 실행할 때 값을 지니지 않은 상태로 열립니다. 로컬 지속성을 유지하는 또 다른 예는 복잡한 웹 사이트에서 사용자 환경 설정이나 기타 데이터(예: 사용자가 뉴스 사이트에서 읽은 기사 레코드)를 추적하는 것입니다. 이 정보를 추적하면 이미 읽은 기사를 읽지 않은 새 기사와 다르게 표시할 수 있습니다. 사용자의 컴퓨터에 이 정보를 저장하면 서버 로드가 줄어듭니다.
  • Maintain local persistence. This is the simplest way to use a shared object, and does not require Flash Media Server. For example, you can call SharedObject.getLocal() to create a shared object in an application, such as a calculator with memory. When the user closes the calculator, Flash Player saves the last value in a shared object on the user's computer. The next time the calculator is run, it contains the values it had previously. Alternatively, if you set the shared object's properties to null before the calculator application is closed, the next time the application runs, it opens without any values. Another example of maintaining local persistence is tracking user preferences or other data for a complex website, such as a record of which articles a user read on a news site. Tracking this information allows you to display articles that have already been read differently from new, unread articles. Storing this information on the user's computer reduces server load.
  •  

  • Flash Media Server에 데이터를 저장 및 공유합니다. 공유 객체는 다른 클라이언트가 검색할 수 있도록 서버에 데이터를 저장할 수 있습니다. 예를 들어 SharedObject.getRemote()를 호출해서 전화번호부처럼 서버에 지속적으로 남아 있는 원격 공유 객체를 생성합니다. 클라이언트가 공유 객체를 변경할 때마다 현재 객체에 연결되어 있거나 나중에 이 객체에 연결하는 모든 클라이언트가 변경된 데이터를 사용할 수 있습니다. 객체가 로컬에서도 영구적이며 클라이언트가 서버에 연결되어 있지 않은 동안 데이터를 변경할 경우, 데이터는 클라이언트가 다음 번에 객체에 연결할 때 원격 공유 객체로 복사됩니다.
  • Store and share data on Flash Media Server. A shared object can store data on the server for other clients to retrieve. For example, call SharedObject.getRemote() to create a remote shared object, such as a phone list, that is persistent on the server. Whenever a client makes changes to the shared object, the revised data is available to all clients currently connected to the object or who later connect to it. If the object is also persistent locally, and a client changes data while not connected to the server, the data is copied to the remote shared object the next time the client connects to the object.
  •  

  • 실시간으로 데이터를 공유합니다. 공유 객체는 여러 클라이언트 간에 실시간으로 데이터를 공유할 수 있습니다. 예를 들어 채팅룸에 연결된 사용자 목록을 저장하고 있는 원격 공유 객체를 열 수 있으며 이 객체에 연결된 모든 클라이언트는 그 목록을 볼 수 있게 됩니다. 어떤 사용자가 채팅룸에 입장하거나 떠나면 그 객체는 업데이트되며 객체에 연결된 모든 클라이언트에 수정된 채팅룸 사용자 목록이 표시됩니다.
  • Share data in real time. A shared object can share data among multiple clients in real time. For example, you can open a remote shared object that stores a list of users connected to a chat room that is visible to all clients connected to the object. When a user enters or leaves the chat room, the object is updated and all clients that are connected to the object see the revised list of chat room users.
  •  

    로컬 공유 객체를 생성하려면 SharedObject.getLocal()를 호출합니다. 원격 공유 객체를 생성하려면 SharedObject.getRemote()를 호출합니다.

    To create a local shared object, call SharedObject.getLocal(). To create a remote shared object, call SharedObject.getRemote().

     

    응용 프로그램을 종료하면 공유 객체는 플러시, 즉 디스크에 쓰여집니다. 또한 flush() 메서드를 호출하여 데이터를 명시적으로 디스크에 쓸 수 있습니다.

    When an application closes, shared objects are flushed, or written to a disk. You can also call the flush() method to explicitly write data to a disk.

     

    로컬 디스크 공간을 고려해야 합니다. 로컬 공유 객체는 응용 프로그램을 설계할 때 중요하게 고려해야 할 몇 가지 한계가 있습니다. 간혹 SWF 파일에서 로컬 공유 객체에 쓸 수 없거나, 사용자가 모르는 상태에서 로컬 공유 객체에 저장된 데이터가 삭제될 수 있습니다. Flash Player 사용자는 개별 도메인 또는 모든 도메인에 대해 사용 가능한 디스크 공간을 관리할 수 있습니다. 사용자가 사용 가능한 디스크 공간을 줄이면 일부 로컬 공유 객체가 삭제될 수 있습니다. 또한 Flash Player 사용자에게는 제3의 도메인(현재 브라우저 주소 막대에 있는 도메인 이외의 도메인)이 로컬 공유 객체를 읽거나 쓰는 것을 방지하는 개인 정보 제어 기능이 제공됩니다. Mac OS에서는 AIR 3.3부터 로컬 공유 객체의 위치가 변경되었으므로 3.3 네임스페이스로 업그레이드할 경우 객체가 손실된 것처럼 나타날 수 있습니다.

    Local disk space considerations. Local shared objects have some limitations that are important to consider as you design your application. Sometimes SWF files may not be allowed to write local shared objects, and sometimes the data stored in local shared objects can be deleted without your knowledge. Flash Player users can manage the disk space that is available to individual domains or to all domains. When users decrease the amount of disk space available, some local shared objects may be deleted. Flash Player users also have privacy controls that can prevent third-party domains (domains other than the domain in the current browser address bar) from reading or writing local shared objects. Also note that on Mac OS, starting with AIR 3.3, the location for local shared objects changed, so if you upgrade to the 3.3 namespace, it may appear as if the objects were lost.

     

    참고: 원격 서버가 아니라 로컬 컴퓨터에 저장되어 실행되는 SWF 파일은 항상 타사 공유 객체를 디스크에 쓸 수 있습니다. 타사 공유 객체에 대한 자세한 내용은 Flash Player 도움말에서 전역 저장 설정 패널을 참조하십시오.

    Note: SWF files that are stored and run on a local computer, not from a remote server, can always write third-party shared objects to disk. For more information about third-party shared objects, see the Global Storage Settings panel in Flash Player Help.

     

    사용할 수 있는 디스크 공간의 양 및 사용자 개인정보보호를 위한 통제와 관련된 실패가 없는지 확인하는 것이 좋습니다. getLocal()flush()를 호출할 때 이러한 사항을 확인합니다.

    Note: SWF files that are stored and run on a local computer, not from a remote server, can always write third-party shared objects to disk. For more information about third-party shared objects, see the Global Storage Settings panel in Flash Player Help.

     

  • SharedObject.getLocal() - 사용자가 타사 공유 객체를 비활성화하고 SWF 파일의 도메인이 브라우저 주소 표시줄의 도메인과 일치하지 않는 경우처럼 이 메서드 호출에 실패하면 Flash Player에서는 예외가 발생합니다.
  • SharedObject.getLocal() — Flash Player throws an exception when a call to this method fails, such as when the user has disabled third-party shared objects and the domain of your SWF file does not match the domain in the browser address bar.
  • SharedObject.flush() - 이 메서드 호출에 실패하면 Flash Player에서는 예외가 발생합니다. 성공하면 SharedObjectFlushStatus.FLUSHED를 반환합니다. 추가 저장 공간이 필요하면 SharedObjectFlushStatus.PENDING을 반환합니다. Flash Player는 로컬에 저장된 정보를 위한 저장 공간 증가를 허용할 것인지 사용자에게 묻습니다. 그런 다음 플러시 실패 또는 성공을 나타내는 정보 객체와 함께 netStatus 이벤트가 전달됩니다.
  • SharedObject.flush() — Flash Player throws an exception when a call to this method fails. It returns SharedObjectFlushStatus.FLUSHED when it succeeds. It returns SharedObjectFlushStatus.PENDING when additional storage space is needed. Flash Player prompts the user to allow an increase in storage space for locally saved information. Thereafter, the netStatus event is dispatched with an information object indicating whether the flush failed or succeeded.
  •  

    SWF 파일이 로컬 공유 객체를 만들거나 수정하려 할 경우, SWF 파일의 크기는 사용자의 로컬 공유 객체 저장 제한을 늘리라는 메시지가 포함된 대화 상자를 표시하는 최소 크기인 폭 215픽셀, 높이 138픽셀 이상이어야 합니다. SWF 파일이 이 크기보다 작고 저장 제한을 늘려야 하는 경우, SharedObject.flush()가 실패하며 SharedObjectFlushedStatus.PENDING을 반환하고 netStatus 이벤트를 전달합니다.

    If your SWF file attempts to create or modify local shared objects, make sure that your SWF file is at least 215 pixels wide and at least 138 pixels high (the minimum dimensions for displaying the dialog box that prompts users to increase their local shared object storage limit). If your SWF file is smaller than these dimensions and an increase in the storage limit is required, SharedObject.flush() fails, returning SharedObjectFlushedStatus.PENDING and dispatching the netStatus event.

     

    원격 공유 객체 Flash Media Server가 있으면 원격 공유 객체를 생성 및 사용할 수 있으며 이러한 객체는 응용 프로그램에 연결된 모든 클라이언트와 실시간으로 공유됩니다. 한 클라이언트가 원격 공유 객체의 속성을 변경하면 그 내역이 연결된 모든 클라이언트에 적용됩니다. 예를 들어 원격 공유 객체를 사용하면 멀티 플레이 게임의 사용자와 같은 클라이언트들을 동기화할 수 있습니다.

    Remote shared objects. With Flash Media Server, you can create and use remote shared objects, that are shared in real-time by all clients connected to your application. When one client changes a property of a remote shared object, the property is changed for all connected clients. You can use remote shared objects to synchronize clients, for example, users in a multi-player game.

     

    각 원격 공유 객체는 data 속성을 지니며, 이것은 데이터를 저장하는 속성을 지닌 Object입니다. 이 데이터 객체의 속성을 변경하려면 setProperty()를 호출합니다. 서버에서는 속성을 업데이트하고 sync 이벤트를 전달하며 다시 연결된 클라이언트에게 속성을 전송합니다.

    Each remote shared object has a data property which is an Object with properties that store data. Call setProperty() to change an property of the data object. The server updates the properties, dispatches a sync event, and sends the properties back to the connected clients.

     

    클라이언트, 서버 또는 양쪽 모두를 선택해서 영구적인 원격 공유 객체를 만들 수도 있습니다. 기본적으로 Flash Player는 로컬에 영구적인 원격 공유 객체를 최대 100K까지 저장합니다. 더 큰 객체를 저장하고자 할 경우 Flash Player는 로컬 저장 대화 상자를 표시하고 이 대화 상자를 사용해 사용자가 공유 객체의 로컬 저장을 허용 또는 거부할 수 있습니다. 스테이지 크기가 215 x 138 픽셀 이상이 되도록 하십시오. 이것은 Flash가 대화 상자를 표시하는 데 필요한 최소 크기입니다.

    You can choose to make remote shared objects persistent on the client, the server, or both. By default, Flash Player saves locally persistent remote shared objects up to 100K in size. When you try to save a larger object, Flash Player displays the Local Storage dialog box, which lets the user allow or deny local storage for the shared object. Make sure your Stage size is at least 215 by 138 pixels; this is the minimum size Flash requires to display the dialog box.

     

    사용자가 [허용]을 선택하면 서버가 해당 공유 객체를 저장해서 netStatus 이벤트를 SharedObject.Flush.Successcode 속성과 함께 전달합니다. 사용자가 [거부]를 선택하면 서버는 해당 공유 객체를 저장하지 않고 netStatus 이벤트를 SharedObject.Flush.Failedcode 속성과 함께 전달합니다.

    If the user selects Allow, the server saves the shared object and dispatches a netStatus event with a code property of SharedObject.Flush.Success. If the user select Deny, the server does not save the shared object and dispatches a netStatus event with a code property of SharedObject.Flush.Failed.

     

    *source : http://help.adobe.com/ko_KR/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html (Korean)

                  http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html (English)

     

     

     

     

    'Adobe Platform > Flex' 카테고리의 다른 글

    History of ActionScript OOP support  (0) 2012.10.04
    mms.cfg(Macromedia Security Configuration)  (0) 2012.09.28
    DispatchEvent Example  (0) 2012.09.25
    NetStreamInfo Class  (0) 2012.09.17
    Capabilities Class  (0) 2012.09.17
    AND