Hotspots and sound


[ Zettels Traum ] [ search / suche ]

von dp am 28.Maerz 97 um 16:00:19:

zu: Perlen aus dem Strom der Nachrichten im direct_L von Daniel am 22.Dezember 96 um 02:00:59:

>
>1: Is it possible to define 'hotspots' (like
>on an image map) on a cast member? or would
>you have to break the picture up into seperate
>sprites?
>
>2: I have a button, when the user clicks on it
>I want a short sound to continue playing (looping??)
>for the duration of the mousedown. How exactly would
>I go about this?

one way to achieve a hotspot on an image would be to place an invisible quickdraw rect above it. More like an image map would be to define a list of rects relative to the topleft coordinate of that image and have a handler check the mouse being inside of any of those.
I would rather use the list of rects since it won't use extra sprites, but construct the list from actual rects.
I make an extra frame I only use for authoring purpose. Place that image at 0,0 and those quickdraw rects where I need them (i.e.: sprite 3, 4 and 5). Now, give this frame a framescript:

on exitframe
set theRectList=[:]
set theSpriteList=[3,4,5]
repeat with theSprite in theSpriteList
addProp theRectList,theSprite,the rect of sprite theSprite
end repeat
put theRectList
halt
end

-- [3: rect(399, 27, 489, 127), 4: rect(118, 26, 202, 152), 5: rect(231, 198, 341, 322)]


Next, this is the script i give that image cast member:

on mouseDown
set theRectList=[3: rect(399, 27, 489, 127), 4: rect(118, 26, 202, 152), 5: rect(231, 198, 341, 322)]
set offH=the left of sprite the clickon
set offV=the top of sprite the clickon
set offset=rect(offH,offV,offH,offV)

repeat with theRect in theRectList
set rslt=inside(the clickloc,(theRect + offset))
if rslt then exit repeat
end repeat

repeat while the stilldown
if not soundbusy (1) then puppetsound 1,"Gong"
end repeat
puppetsound 1,0

if rslt then put getOne(theRectList,theRect)
end

Now, I have a frame with my image and a framescript

on exitFrame
go to the frame
end

that keeps me looping there.

Assumed there is a sound cast member named "gong" you will hear that sound repeated while the mouse is down. If a hotspot has been hit you will find the corresponding number in the message window, you then might insert something like

if rslt and getOne(theRectList,theRect) = 3 then doSomethingSmart

Hope this helps

Daniel Plaenitz



Dazu:























D. Plänitz