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
Thank you.
--
Nicolas Cueto