I had to rework it a little bit. Here is the exact step-by-step breakdown (plus explainations)
1. Double click on the hotspot you want people to click on to trigger the actions.
2. Click on "Advanced"
3. Click the "Variables..." button towards the bottom. This will open your Global Variables window.
4. Click "New Integer Variable..."
An integer variable can only contain whole positive numbers. On the other hand, a variant variable can contain just about any characters - letters, symbols, numbers, etc.
5. Type "htsppic", and click "OK". This will create a new integer variable under the name you just typed in.
6. Click "OK" on the Global Variables window. This will take you back to the hotspot properties window.
7. In the "Enter VBScript code:" box, enter this code:
- Code: Select all
randomize
htsppic = int(rnd*(4-1+1))+1
'This selects a random number between one and four, and saves it to our "htsppic" variable.
Select Case (htsppic)
Case "1":
Action.LoadAPicture Hotspot(1), "AF.JPG"
Action.CreateTimedEvent 5, "TARGET_FRAME", 0
Case "2":
Action.LoadAPicture Hotspot(1), "PAT.JPG"
Action.CreateTimedEvent 5, "TARGET_FRAME", 0
Case "3":
Action.LoadAPicture Hotspot(1), "K.JPG"
Action.CreateTimedEvent 5, "TARGET_FRAME", 0
Case "4":
Action.LoadAPicture Hotspot(1), "NICK.JPG"
Action.CreateTimedEvent 5, "TARGET_FRAME", 0
End Select
'This triggers an action based on the number in the "htsppic" variable that was randomly selected.
Now, replace "TARGET_FRAME" on each Case with the name of the frame you want to go to when the picture listed above it is shown.
Make sure you enclose the frame name in quotes!
Note, I used a select case system, which checked the contents of the variable "htsppic". Then, based on the result, it loaded a picture into hotspot one, and created a non-repeating timed event for five seconds that would go to a target frame when the five seconds had passed.
If you have trouble, the first three things to look at are...
a) Does the name of the variable you declared in Global Variables match up EXACTLY with the one in the code?
b) Are the target frame names and image names correct?
c) Are the image names and target names in quotes? Is all the rest of the syntax (scripting "grammar") correct?
(The code posted above SHOULD be free of errors, as I either tested or cross-checked the syntax of each element. But, if you copy and paste, and get a syntax error, I'll take another look.)
I hope this helps!
-J