clone problem

Nicolas Cueto niconiko at
Tue Dec 6 17:12:11 EST 2011

Hell All,

I have a script that does not always work as expected.

>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 clicked on originally
apparently at its original location, and the new image apparently now
in the new location.

The problem visually is that it seems like the original image becomes
draggable, and the cloned image gets left behind.

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

Also, instead of mouseDown, I'm using AnimationEngine's

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.

Here is the actual script:

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 ""
end constrainRectangularInit

If anyone understands and can help, I'd much appreciate it.

Thank you.

More information about the Use-livecode mailing list