constrainRectangular ... and doubleMouseUp?

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

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
niconiko
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 32
Joined: Mon Jul 17, 2006 2:28 am
Location: Motegi, Japan

constrainRectangular ... and doubleMouseUp?

Post by niconiko » Wed Dec 07, 2011 2:37 am

Hello Malte,

I posted this first on the LC list. Apologies for crossposting to here.

I have a script that does not always work as expected. I think the problem is related to constrainRectangular, and is perhaps trigerred by mouseDoubleDown or mouseDoubleUp. But I'm not sure.

From the student's point of the view, the script allows them to click and drag an alphabet letter for release onto a writing area. That way, there's two images visible : the image they originally clicked on and a new image which seems to be moveable to a new location.

What the script is actually doing in the background is on mouseDown the original image is cloned, the clone gets the original image's name, and the original image gets a new name. Similarly, their layering is switched too. That was the only way I could think of to allow an image to become draggable and cloned at the same time, i.e., without mouseUp

Of course, instead of mouseDown, I'm using AnimationEngine's constrainRectangularInit.

The problem with my script is that sometimes the image that's supposed to stay in place becomes the image that's supposed to be draggable. I assume the problem happens in the renaming my script does. And I also assume that mouseDoubleDown or mouseDoubleUp is the problem.

Here is the actual script:

Code: Select all

on constrainRectangularInit
  deleteClonedHilites -- deletes unneeded graphic objects
  put the short name of me into tGrabbedImg
  if "_" is not among the chars of tGrabbedImg then
     ## the char "_" is added by my script when renaming
     clone invisible image tGrabbedImg
     put word 3 of it into tNewImgID
     put tGrabbedImg & "_" & the milliseconds into tNewImgName
     set the name of me to tNewImgName
     put the cpCloned_Letters of this card into tTemp
     put tNewImgName & cr after tTemp
     set the cpCloned_Letters of this card to tTemp
     set the name of image id tNewImgID to tGrabbedImg
     set the loc of image id tNewImgID to the loc of me
     set the layer of image id tNewImgID to the layer of me
     show image id tNewImgID
  end if
  set the layer of me to top
  put item 1 of the clickLoc into sX
  put the milliseconds into sLastTime
  put true into sMove
  play "letter_pickup.au"
end constrainRectangularInit

If that makes sense, I'd much appreciate your help.

Thank you.

--
Nicolas Cueto

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

Re: constrainRectangular ... and doubleMouseUp?

Post by malte » Wed Dec 07, 2011 12:06 pm

Hi Nicolas,

I am afraid I need a little more explanation (maybe a boild down test case you could send me?)

All I can say that ae should be name agnostic. It references the long ID internally.

All the best,

malte

niconiko
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 32
Joined: Mon Jul 17, 2006 2:28 am
Location: Motegi, Japan

Re: constrainRectangular ... and doubleMouseUp?

Post by niconiko » Thu Dec 08, 2011 10:45 pm

Thanks Malte. But, during debugging found mouseDoubleDown was being read (even though there's no handler for it in my script), and figured that it was happening during the time it took my messy constrainRectangularCallback and constrainRectangularExit handlers to finish executing, so reconsidered the visual effect and completely simplified my code.

Cheers.
--
Nicolas Cueto

Post Reply

Return to “Animation Engine”