I'm trying to use this code for a chain-reaction collision between an indefinite number of text-fields which have been set with constrainRectangular
Code: Select all
on constrainRectangularCallback put the loc of me into tGrabbedLoc put the rect of me into tGrabbedRect put the objects of this card into tStationaryFields filter tStationaryFields with "*pasted object*" filter tStationaryFields without (the name of me) repeat for each line tStationaryField in tStationaryFields put word 2 of tStationaryField into tStationaryFieldName replace quote with "" in tStationaryFieldName put the rect of field tStationaryFieldName into tStationaryRect put the loc of field tStationaryFieldName into tStationaryLoc put intersectrect(tGrabbedRect,tStationaryRect) into tIntersectRect if tIntersectRect <> "false" then ## The grabbed field has been bumped into a stationary field. put tGrabbedRect & "|" & tStationaryRect into tTheTwoRects switch directionToNudgeTheStationaryRect(tTheTwoRects) case "nudge stationary to the right" put item 1 of tStationaryLoc + \ (item 3 of tIntersectRect - item 1 of tIntersectRect) & comma & \ item 2 of tStationaryLoc into tNudgedLoc aeMoveTo the long ID of field tStationaryFieldName,tNudgedLoc,500,"out" break case "nudge stationary to the left" put item 1 of tStationaryLoc - \ (item 3 of tIntersectRect - item 1 of tIntersectRect) & comma & \ item 2 of tStationaryLoc into tNudgedLoc aeMoveTo the long ID of field tStationaryFieldName,tNudgedLoc,500,"out" break end switch else -- don't nudge end if end repeat end constrainRectangularCallback
http://www.screentoaster.com/watch/stWE ... lcW1xcUFJS
In the video you can see three fields aligned from left to right : "Do", "am", and "are". When "Do" is grabbed and moved near "am", aeMoveTo causes "am" to get bumped away from "do".
So far so good.
My next goal is for "am" to also bump away "are" when it gets bumped close enough.
If there's something in ae that can make this easier, please let me know.