Hi,
couldn't resist.
the stack is here:
http://derbrill.de/revstack/AEDrag.rev
It requires animationEngine to be loaded and in use. Open up animationengine and type
start using stack "animationEngine" into the messagebox.
I created a stack, 1 button,3 flds, 3 grcs. LockText of flds=true, traversalOn=false. Each field owns a custom property calle cInitialPositian, which holds the loc, the field should snap back to. The script in the reset button calls a handler "resetGame" in the card script. The card owns this script:
Code: Select all
--> all handlers
-- quick AE drag and drop Demo
on openCard
resetGame
end openCard
on resetGame
if "animationEngine" is not among the lines of the stacksinuse then
if "animationEngine" is among the lines of revLoadedStacks("application") then
start using stack "animationEngine"
else
answer "This stack needs animationEngine to run!"
exit resetGame
end if
end if
aeLockMoves
aeMoveTo the long id of fld "fld,red",the cInitialPosition of fld "fld,red",200,"inout"
aeMoveTo the long id of fld "fld,green",the cInitialPosition of fld "fld,green",200,"inout"
aeMoveTo the long id of fld "fld,yellow",the cInitialPosition of fld "fld,yellow",200,"inout"
aeUnlockMoves
set the constrainRectangular of fld "fld,red" to the rect of this card
set the constrainRectangular of fld "fld,green" to the rect of this card
set the constrainRectangular of fld "fld,yellow" to the rect of this card
end resetGame
on constrainRectangularExit
local tColor
put item 2 of the short name of the target into tColor
if the mouseloc is within the rect of grc ("grc,"&tColor) then
set the constrainRectangular of the target to empty
aeMoveTo the long id of the target,the loc of grc ("grc,"&tColor),300,"overshoot"
else
aeMoveTo the long id of the target,the cInitialPosition of the target,350,"bounce"
end if
end constrainRectangularExit
If you have any questions, please feel free to ask.
Cheers,
Malte