Random Hotspot location

Bill Marriott wjm at wjm.org
Mon Jun 5 05:28:33 EDT 2006


Every "object" (or more correctly, "control") in Revolution has a location 
(or "loc") which is the x, y coordinate where that object is located. You 
can easily get and set the location of objects.

Here's one way you could build your program using locations:

1. Put in your backdrop image.

2. Make small, square-ish buttons for each one of the hotspots. For 
convenience, name each button with the corresponding letter of the alphabet. 
Don't worry about making them invisible for now, but do position them where 
you want them to be.

To make quick work of this, just draw the first button, then duplicate it 
and position it repeatedly. Then open up the message box, switch to the 
multiline mode, and enter this short script:

repeat with i = 1 to the number of buttons
set the name of button i to char i of \
  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
end repeat

3. Import as a Control the image you are using for the pointer. 
(Control-Shift-.) Name it "MyPointer" -- a PNG with a transparent hole cut 
out for the "Viewing Hole" works great. Another approach is to set the blend 
mode of the pointer graphic to 50% so it's somewhat translucent.

4. Create a new field, "MyWords" off to the side. Switch to run mode (white 
arrow) and enter a few words into the list, separated by returns.

5. Put a button below the word list named "Spell It Out" and put this in for 
the script:

on mouseUp
  put random(the number of lines in fld "MyWords") into n
  repeat for each char x in line n of fld "MyWords"
    move img "MyPointer" to the loc of btn x in 2 secs
    wait 200 milliseconds
  end repeat
end mouseUp

When you click the button you'll see the pointer move to each letter, 
pausing briefly at each.

What about all those ugly buttons? Hide/Show them by creating a new button 
with this script:

on mouseUp
  repeat for each char n in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    set the visible of button n to not the visible of btn n
  end repeat
end mouseUp

Clicking the new button will hide or show the buttons used as "hot spots."

I uploaded a sample stack to Rev Online. Look under "MerryOtter" for the 
stack "Moving Pointer."

Cheers,

Bill


<SupermanSlyr at aol.com> wrote in message 
news:4cc.e2168.31b54798 at aol.com...
> I'm sure this is easier than I think, but I seem to be having some 
> trouble.
> I have a relatively simple program in mind. Imagine an image with 
> multiple
> hot spots that have been labeled with letters. I desire to make a  program 
> with
> an image pointer that randomly selects a word or phrase from a text  file, 
> and
> then spells it out on the image where the corresponding letters are on 
> the
> background image. So, to clarify there are two images: one image is the
> background (The one with all the letters), the second is the pointer image 
> (Which
> points to the letter). Think of an Ouija board (Only without the board). 
> I'd
> also like to move the pointer around and select random letters. Maybe it's 
> the
> random stuff that keeps throwing me off. What's so frustrating is I know
> it's possible. And it genuinely sounds very simple. What would be the best 
> way
> to define the hot spots on the image? And how can I get the random moving
> pointer to work right? Any thoughts, pointers, or assistance on this 
> project  will
> be greatly appreciated.
>
>
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 






More information about the use-livecode mailing list