after deciding what your end point is going to be (maxThatSpriteH)

newLocH = sprite(spriteNum).locH + iAmountToMove
sprite(spriteNum).locH = max(thatSpriteH, min(maxThatSpriteH, newLocH) )

roymeo

At 10:24 AM 12/14/01 +0800, you wrote:
>Hi List,
>
>I'm trying to develop a mouseover effect. Ok, here's the deal.
>
>When a user's mouse cursor moves closer to the button, a corresponding
>sprite would then fade in. The level of fade [sprite(me.spriteNum +
>1).blend] depends on the distance between the button and the mouse
>cursor. So let's say the distance between the mouse is 90 pixels, then
>the corresponding sprite's blend level would be 10. As the mouse cursor
>moves closer to the button and eventually over the button, the blend
>level would be 100, whih is the maximum. I've got this part covered. No
>problems.
>
>The problem occurs when i want to move the corresponding sprite as well.
>Same concept, just that when the mouse cursor moves closer to the button
>the corresponding sprite would then move horizontally to the right. I
>want the sprite to move only a maximum of 150 pix.
>
>Example:
>distance between mouse cursor and button = 90
>sprite would move 10% of the 150 pix = 15 pixels
>
>I know im being long-winded....but i just want to be clear.
>
>I've included my lingo code for this. But it doesn't work (the moving part):
>
>global spriteDis --the distance the sprite is supposed to move
>property thatSprite --the moving sprite
>property thatSpriteH --the moving sprite's initial locH
>
>on beginSprite me -- assign initial variables
>thatSprite =3D sprite(me.spriteNum + 1)
>spriteDis =3D 150
>thatSpriteH =3D thatSprite.locH
>end
>
>on exitFrame me
>h = sprite(me.spriteNum).locH -- button's locations
>v = sprite(me.spriteNum).locV
>diffh = abs(the mouseh - h) -- the distance between the mouse cursor and the
>button
>diffv = abs(the mousev - v)
>endDis = thatSpriteH + spriteDis -- the end location of the moving sprite
>
>if diffh < 100 and diffv < 100 then -- if mouse cursor is within 100pixels
>of the button
>if diffh < diffv then
>thatSprite.blend = abs(100 - diffv) -- fade in moving sprite
>thatSprite.locH = (diffv/100) * endDis + thatSpriteH -- ??move the sprite??
>(not working!!)
>else
>thatSprite.blend = abs(100 - diffh) -- fade in moving sprite
>
>thatSprite.locH =3D (diffh/100) * endDis + thatSpriteH -- ??move the
>sprite?? (not working!!)
>end if
>else
>sprite(me.spriteNum + 1).blend = 0 --hide moving sprite
>end if
>end
>
>Hope someone can give me some pointers.
>P.S. If possible, please reply to me direct via my email at
>[EMAIL PROTECTED] , cos' i'm receiving the digest version. And I
>need a solution fast!...Thanx!
>
>Thanks again!
>Ching Ian
>Fortress Vision Sdn. Bhd.
>Malaysia
>
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
>email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo.  Thanks!]


-----
Roy Crisman
Senior Macromedia Programmer
(716)724-4054
[EMAIL PROTECTED]


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to