Share via


Character 개체 메서드

[Microsoft 에이전트는 Windows 7을 기준으로 더 이상 사용되지 않으며 이후 버전의 Windows에서는 사용할 수 없습니다.]

또한 서버는 Characters 컬렉션의 각 문자에 대한 메서드를 노출합니다. 지원되는 메서드는 다음과 같습니다.

메서드를 사용하려면 컬렉션의 문자를 참조합니다. VBScript 및 Visual Basic에서는 문자의 ID를 지정하여 이 작업을 수행합니다.

   Sub FormLoad

   'Load the genie character into the Characters collection
   Agent1.Characters.Load "Genie", "Genie.acs"

   'Display the character
   Agent1.Characters("Genie").Show
   Agent1.Characters("Genie").Play "Greet"
   Agent1.Characters("Genie").Speak "Hello. "

   End Sub

코드 구문을 단순화하기 위해 개체 변수를 정의하고 Characters 컬렉션의 문자 개체를 참조하도록 설정할 수 있습니다. 변수를 사용하여 문자의 메서드 또는 속성을 참조할 수 있습니다. 다음 예제에서는 Visual Basic Set 문을 사용하여 이 작업을 수행하는 방법을 보여 줍니다.

   'Define a global object variable
   Dim Genie as Object

   Sub FormLoad

   'Load the genie character into the Characters collection
   Agent1.Characters.Load "Genie", " Genie.acs"

   'Create a reference to the character
   Set Genie = Agent1.Characters("Genie")

   'Display the character
   Genie.Show

   'Get the Restpose animation
   Genie.Get "animation", "RestPose"

   'Make the character say Hello
   Genie.Speak "Hello."

   End Sub

Visual Basic 5.0에서는 변수를 Character개체로 선언하여 참조를 만들 수도 있습니다.

   Dim Genie as IAgentCtlCharacterEx

   Sub FormLoad

   'Load the genie character into the Characters collection
   Agent1.Characters.Load "Genie", "Genie.acs"

   'Create a reference to the character
   Set Genie = Agent1.Characters("Genie")

   'Display the character
   Genie.Show

   End Sub

IAgentCtlCharacterEx 형식의 개체를 선언하면 개체에 대한 초기 바인딩이 가능하므로 성능이 향상됩니다.

VBScript에서는 참조를 특정 형식으로 선언할 수 없습니다. 그러나 변수 참조를 선언하기만 하면 됩니다.

<SCRIPT LANGUAGE = "VBSCRIPT">
<!—--

   Dim Genie
   
   Sub window_OnLoad
   
   'Load the character
   AgentCtl.Characters.Load "Genie", "https://agent.microsoft.com/characters/v2/genie/genie.acf"

   'Create an object reference to the character in the collection
   set Genie= AgentCtl.Characters ("Genie")

   'Get the Showing state animation
   Genie.Get "state", "Showing"

   'Display the character
   Genie.Show

   End Sub

-->
   </SCRIPT>

일부 프로그래밍 언어는 컬렉션을 지원하지 않습니다. 그러나 Character 메서드를 사용하여 Character 개체의 메서드에 액세스할 수 있습니다.

   agent.Characters.Character("CharacterID").method

또한 Character 개체에 대한 참조를 만들어 스크립트 코드를 더 쉽게 따를 수 있습니다.

<SCRIPT LANGUAGE="JScript" FOR="window" EVENT="onLoad()">
<!--
   
   //Load the character's data
   AgentCtl.Characters.Load ("Genie", _
      "https://agent.microsoft.com/characters/v2/genie/genie.acf");   

   //Create a reference to this object
   Genie = AgentCtl.Characters.Character("Genie");
   
   //Get the Showing state animation
   Genie.Get("state", "Showing");

   //Display the character
   Genie.Show();

-->
</SCRIPT>