Pb with mouveEnter & mouveLeave

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
davidh31
Posts: 3
Joined: Tue Aug 28, 2012 10:27 am

Pb with mouveEnter & mouveLeave

Post by davidh31 » Tue Aug 28, 2012 4:15 pm

Hi,

I'm new to Livecode and animationEngine.

I'm trying to animate a button made of different parts (a group). A figure (as attached) is better than a lot of text.
The 'button template' template groupe has two handler :

on mouseEnter
-- La souris survole le bouton.
aeLockMoves
aeMoveTo the long ID of graphic "Triangle", the item 1 of the loc of graphic "Triangle" + 8, the item 2 of the loc of graphic "Triangle" , 250, "bounce"
aeChangeBackColor the long ID of graphic "Rectangle", 97, 150 , 195, 250, "in"
aeChangeForeColor the long ID of field "Button text", 255, 255, 255, 250, "in"
aeChangeBackColor the long ID of graphic "Triangle", 255, 255, 255, 250, "in"
aeUnlockMoves
end mouseEnter

on mouseLeave
-- La souris cesse de survoler le bouton.
aeLockMoves
aeMoveTo the long ID of graphic "Triangle", the item 1 of the loc of graphic "Triangle" - 8, the item 2 of the loc of graphic "Triangle", 250, "bounce"
aeChangeBackColor the long ID of graphic "Rectangle", 255, 255 , 255, 250, "in"
aeChangeForeColor the long ID of field "Button text", 169, 169, 169, 250, "in"
aeChangeBackColor the long ID of graphic "Triangle", 169, 169, 169, 250, "in"
aeUnlockMoves
end mouseLeave

So, i want some parts to change colors when the mouse is over the buton. I also want the graphic 'Triangle' to move. All appears to work well. But when the mouse move between the 'Triangle' and the text 'Home', it seems that only the mouveLeave event is fired, and so the graphics 'Triangle' move a little each time.

Please, can someone help me with this issue ?

Thanks.

David
Attachments
Live code screen capture.gif
Screen capture

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Pb with mouveEnter & mouveLeave

Post by malte » Tue Aug 28, 2012 7:32 pm

quickest way to help you (other help would require to read up on the way the whole messaging system in the liveCode engine works, which would go too far here)

Edit the group, place an opaque graphic at the topmost layer of the group. Set the ink of the graphic to noOp. This will make the graphic appear to be invisible, but still traps messages. Place the code you have in the group at the moment in the script of the graphic and remove it from the group. This is a quick and dirty workaround, however getting into the way the engine digests messages is a little too much for me to explain right now to show you a "more correct" solution.


You can read up on the message path at a few places, including this:

http://www.fourthworld.com/embassy/arti ... _path.html

Hth,

Malte

davidh31
Posts: 3
Joined: Tue Aug 28, 2012 10:27 am

Re: Pb with mouveEnter & mouveLeave

Post by davidh31 » Wed Aug 29, 2012 9:55 am

Hi Malte,

Thanks for your help.

Howerver this does not work. There is already a graphic on the topmost layer (in my screen capture it is the 'Rectangle'). This graphics becomes blue when the mouse is over. With an ink set to 'noOp' the color is not visible and all the text and graphic of the button disappear.

Il will investigate your link to try to understand what i missed in the message path.

best regards,

David

davidh31
Posts: 3
Joined: Tue Aug 28, 2012 10:27 am

Re: Pb with mouveEnter & mouveLeave

Post by davidh31 » Wed Aug 29, 2012 11:13 am

Hi

I've played with graphics and animation engine for a while and i've found somthing :

1- Put a graphic on a stack (i've named my graphic 'Triangle') ;

2- Code the mouseEnter and mouseLeave as follow :

on mouseEnter
aeMoveTo the long ID of graphic "Triangle", the item 1 of the loc of graphic "Triangle" + 8, the item 2 of the loc of graphic "Triangle" , 250, "bounce"
end mouseEnter

on mouseLeave
aeMoveTo the long ID of graphic "Triangle", the item 1 of the loc of graphic "Triangle" - 8, the item 2 of the loc of graphic "Triangle", 250, "bounce"
end mouseLeave

3- go in Run mode ;

4- all works well when the mouse enter the graphic, and stay on it : at this moment the graphic moves. When the mouse leave the graphic, it comes back in place.
However when the mouse cross the graphic, only the mouveLeave handler is called, and the graphic moves a few pixels back.

My problem comes form the fact that when the mouse crosses the graphic, only the mouseLeave get called.
I'm using LiveCode 5.5.1 and animationEngine 5.0.2. Is it a bug ?

Thanks

David

Post Reply

Return to “Animation Engine”