Saturday, May 24, 2003

Authorware and WinAPI are there any references? - Part 1


Have you ever tried to use any functions from the WinAPI.u32 supplied with Authorware? If so you will no doubt have been frustrated by the 'information' provided with the functions. If not, here's a quick example.

Imagine you want to copy a file from your application CD to the user's hard drive. What Authorware function would you use? Seems like a simple enough request doesn't it? Well there is no native CopyFile() function in Authorware. There are many options for solving this problem, one of which is to load the CopyFile() function from WinAPI.u32. So let's try it.

1. Open a new Authorware file, and save it somewhere convenient as TestCopy.
2. You need a test file to copy, so make a new text file in the same folder you just saved your Authorware file into. Call this text file TextCopy.txt,
and type some text in it. Something simple like Hello Mum.

Now we need that CopyFile() function. Loading a new function into Authorware from a .u32 is pretty simple.

3. Open the Functions dialogue either by pressing the Functions button or pressing the keys control+shift+f.
4. Click in the Category: drop-down and scroll down to the bottom until you find a category named TestCopy.axp (where the x in axp represents your version of Authorware - a4p for Authorware 4, a5p for Authorware 5 etc.) and select this category.
5. Press the Load button at the bottom-left of the Functions dialogue.
6. A Windows browse dialogue entitled Load function appears. Use it to browse to the folder containing your current version of Authorware - by default it should be:-

C:\program files\macromedia\Authorware x
(x will be your Authorware version number - 4, 5, 6, 6.5 ...)

Now here you take a sneaky shortcut. It is best to load your function from a u32 that is in the same folder as your application. When you do this Authorware stores the reference to the file as a relative reference, not a hard-coded path. Whilst it should not matter once the file is packaged, it is more elegant to use the relative path during development plus it helps to ensure that you package the correct files with your application.

So the sneaky shortcut is this:- Locate the file WinAPI.u32 in the browse dialogue, select it with a SINGLE mouse click and then press Control+C to copy the file to your clipboard. Keeping the browse dialogue open, now browse to the folder that you have saved your test file into. With the folder open, press Control+V to paste the WinAPI.u32 into your test folder.

Continued in part 2 below

No comments: