Knowledge Objects for Dummies
If you’re like me, this Knowledge Object thing scares you to death. You know it is a powerful tool, but you can’t quite figure out what that tool does or how it does it. You’ve read all the help files and the section in the manual, but you’re still a little perplexed. Think of it this way. You just built a new treehouse in the oak tree in your back yard. Your friend, Timmy, has a treehouse in the elm tree on the other side of the fence. Timmy wants help with his homework, and you have a set of Encyclopedias in your treehouse that’s too heavy to move to Timmy’s treehouse. One day, you get an idea! You connect two tin cans with a piece of string and climb up in Timmy’s treehouse. You leave a note for Timmy to throw you a tin can next time he climbs the tree. That way, you can give Timmy directions to finish his homework. Knowledge Objects work the same way. A Knowledge Object is one Authorware file that can communicate with another through a communications link, otherwise known as a Knowledge Object Icon. Before Timmy can toss you a tin can, you must have a treehouse of your own to catch it. By the same token, before you try to use a Knowledge Object Icon that has a wizard, there must be a file set up for it to link to. This can be an empty file or a file that you think will have the desired result if you link to it. Save the file with a descriptive name. When Timmy climbs the tree, he sees a note that says “Toss one of these tin cans to me in the elm tree.” When Authorware encounters an unlinked Knowledge Object Icon, it will ask you where you want to throw your tin can. Not only will it want the file name; it will want a unique Knowledge Object ID. This helps the Knowledge Object Icon and the file it calls to recognize each other. Macromedia provides some guidelines to help you make up this number, but it has also helpfully provided a Knowledge Object that will generate one for you. Generate this number and have it handy before you try to use your unlinked Knowledge Object Icon. Once you’ve filled in the blanks in the dialogue box with your KO properties, you’ll be asked where your wizard file is. Locate the file you saved earlier, and voila! it opens in a second instance of Authorware. Now you’re ready to start development on your wizard. Communicating between two separate instances of Authorware may seem complex, but you don’t have to be a magician yourself to understand it. Once Timmy has opened communication with your treehouse, Timmy can’t
do anything that you don’t tell him to until you put down your tin can
(i.e., your wizard quits). Note that as of Authorware 6.5, we have nonmodal
Commands, which don't have to quit before you can tinker around with your
Target file by hand. So the first thing you want to do is find out what
his first homework problem is. Regardless of whether you want to ask Timmy
a question or tell him to do something, the first thing you have to do
is pick up your tin can. The function “CallTarget” is like picking up
the tin can and saying, “Hey, Timmy, listen up!” To say, “Hey, Timmy,
listen up! What’s your first homework problem?” from your wizard to the
target piece might look like: Unless you only want the initial value of "Homework 1," make sure to place your KO on the flow line after the variable is set. In real life, you are more likely to use this function to get system variables. Once you find out what the homework problem is, you will look up the answer. Looking up the answer, or anything else that happens in your treehouse, is exactly like the familiar Authorware code you are used to writing. So, if you needed to query a database, parse the question string, or whatever else, you will not need to route it through the "CallTarget" function. Now that you've determined the correct answer, you need to tell Timmy
to do something about it. This can be as simple as setting a variable: Note that in this example you are using the "CallTarget" function to access the SetVariable function and that "Homework 1 ans_wiz" is a variable that will become the value of the variable Correct Answer. This brings up the point that you can use most of the Authorware System functions this way. The important thing to remember is that the name of the function itself and all of its parameters are strings that are used by the "CallTarget" Function. When the information gets to the target file, it will sort the parameters out to look the way the specific function wants to see them. Get the order right, but ignore parentheses, @ signs, etc. Remember that the @ sign is Authorware's way of ensuring that what is to the right of the @ sign refers to an IconID. So make sure that any thing you pass to CallTarget that has an @ sign in it is a valid IconID in the target piece. Another thing you may want to do is hand Timmy a folder filled with homework answers that he could use, then tell him which one to use based on the question. Of course, in an Authorware file, these would be models that you would use the PasteModel function to insert into the file. Let's take a look at the PasteModel documentation to see how we'd translate it to a "CallTarget" statement:
Right off the bat, you can see that the word "CallTarget" is
nowhere to be found in this statement. You can also see that there are
parentheses. So we need to take this syntax and change it a little so
that it fits into the "CallTarget" function. The new statement
should look like this: In Authorware 6.5, you can actually insert blank icons without using a model, and in Authoware 7, you can use the BuildDisplay to dynamically create the contents of that icon. You also may find that you want to include logic within the KO icon itself that your wizard can modify. The KO icon is really just a special type of Map icon, but it can be a tough nut to crack if you've never opened one. To open the KO, press Control-I to open the Icon Properties Dialogue, then press the Open button. Your logic within the KO will be ordinary Authorware icons. You will need to use CallTarget in the wizard to modify the icons inside your KO, but you will not need CallTarget in those icons. Commands are essentially the same thing as KO's, but they are launched from the Command menu, and TargetIcon contains the same ID as RootIcon, rather than being the KO icon. In fact, commands are not associated with a KO icon at all. That's really all there is to it. The bulk of your work will be done in the wizard file using perfectly ordinary Authorware logic. When you want to get something from the target file or put it into the target file, you use either the familiar Authorware functions you use every day or the Target Authorware functions, wrapped up in a CallTarget statement. When you paste a model into the file, remember that it is just an ordinary piece of an ordinary Authorware flow line, and does not need to be any more complex just because it is being inserted by a Knowledge Object. Now that you have a basic "nuts and bolts" view of how a Knowledge Object works, go read the Knowledge Objects—Step By Step page on the Authorware Help Pages. They should make a little more sense. |