Let your webpage more exciting
- Simple application on Microsoft Agent on the web
DETROX
(This article assumes that you use WindowsXP or Windows2000 operating systems) I don't know if you have a little wizard when he drives a web page, the blue robe is full of golden stars and the moon is very cute. He will ask you to introduce you to this website. You must be strange, how the wizard is made. In fact, he is not a web page but a Microsoft Agent called Microsoft Agent. Today, let's discuss how to add this cute agent (he called Merlin) in your web page.
The official role of Microsoft Agent In addition to the wizard Merlin, which comes with WindowsXP and 2000, there is additional geographical colors that need to be downloaded from http://www.microsoft.com/msagent/downloads/user.asp#character. They are the monsters in the bottle (still remember that song), parrot peedy and robot Robby. Downloading the file is an exe file, you can complete the installation directly.
In our webpage, you can load our Agent through JavaScript to call Agent.Control.2. The specific method is as follows:
Var chname;
VAR Agent;
VAR CH;
chname = "merlin";
Agent = New ActiveXObject ("Agent.Control.2");
Agent.connected = true;
Agent.characters.Load (chname, chname ". ACS");
CH = agent.characters (chname);
Code explanation:
Chname is the name of the role we want to use, because more out to use it, so save it into a word type variable, here we define it to "merlin". Agent Specifies an object variable for Agent.control.2 Agent.connected = true to start the microsoft agent connection agent.characters.Load () read into the role you want to use, he has two parameters, the first is the role Name, the second is a file that is stored.
By the way, the Microsoft Agent role is saved in the Chars folder in the Msagent folder in the Windows directory. In general, its file name and role name are the extension of the same role file is .acs. CH = agent.Characters () Let Ch = A manipulation variable in the role, and we can make our roles in a variety of movements. For example, we want to use the Speak behavior to enter Ch.Speak ("Hello"); this part of the code is basically a template, and the Copy & Paste is OK when applying.
Ok, now our role has read memory. Let's discuss some common basic roles.
Basic role behavior (as an example of Merlin)
Show () makes the role on the screen. The role that has just created is that you can't call the show () function.
Hide () relative to show () functions, used to hide the role from the screen (not removed from memory)
Speak (Words) Let our role "speak", the content of Words will be displayed in a language balloon, Words is a string
Think (Words) Words content will be displayed in a thinking balloon, Words is a string
Moveto (X, Y) moves to the screen (x, y)
Play (ANI) uses role animation ani as a string. Its value can be
Announce
EXPLAIN
CONGRATUATE
DONTRECONGNIZE
GESTUREDOWN
GESTURELEFT
GESTURHT
GESTUREUP
Greet
Pleased
Reta
Surprised
IDEL1_1 to Ideal1_4
IDEL2_1 and Idel2_2
Here, only part of Merlin, the specific animation instructions can see the contents of the MSDN's Microsoft Agent Animations for .... You can also download the Agent's help file from Microsoft's website without MSDN.
Ok, introduce the simplest application of Microsoft Agent here, let's take a look at an example.
Program case
Var chname;
VAR Agent;
VAR Merlin;
chname = "merlin";
Agent = New ActiveXObject ("Agent.Control.2");
Agent.connected = true; agent.characters.load (chname, chname ". acs");
Merlin = agent.characters (chname); Merlin.moveto (200, 200); Merlin.show ();
Merlin.Play ("Announce");
Merlin.Speak ("Welcome to the personal home page" of DETROX);
Merlin.Play ("explain");
Merlin.speak ("cough, here you have included DETROX and his friends. I hope you can like it.");
Merlin.Play ("iDle1_1");
Merlin.Play ("pleased");
Merlin.speak ("Please come, my guest");
Merlin.moveto (600, 300);
Merlin.Play ("surprised");
Merlin.speak ("Oh is right, everyone is recently be careful. A lot of attention");
Merlin.Play ("iDle1_2");
Merlin.Play ("Gestureup");
Merlin.speak ("I wish you a happy");
Merlin.Play ("Read");
Merlin.hide ();
script>
body>
html>
Here is only the simplest usage of Microsoft Agent. The purpose of Microsoft Agent is to provide us with a voice command environment, just helplessly do not have Chinese language packages, we can't understand his convenience. You can refer to the description of the speech usage of the Agent in the MSDN.