Hi John: You really should use "send in..." to allow for interruptions of a loop.
Without knowing exactly what kind of motion you are trying to achieve, here's how I would do it: -- SINCE YOU ARE USING FIELD 1 AS A SWITCH, -- YOU CAN TREAT IT AS SUCH, BEING EITHER ON (TRUE) OR OFF (FALSE) -- IN THIS CASE ALL REFERENCES TO "FIELD 1" ARE -- EITHER TRUE OR FALSE local moveCount -- STORES THE NUMBER OF TIMES THE BALL HAS MOVED on mouseUp put not fld 1 into fld 1 if fld 1 then put 0 into moveCount -- RESET THE LOOP COUNTER moveTheBall end if end mouseUp on moveTheBall if not fld 1 or moveCount = 20 then exit moveTheBall move grc 1 rel 0,10 -- MOVES THE BALL DOWN 10 PIX add 1 to moveCount send "moveTheBall" to me in 10 millisecs end moveTheBall The first line of moveTheBall will exit the handler if field 1 contains "false" or if the number of move loops = 20. You should be able to interrupt the ball's motion at any time thanks to the "send..." command at the end of the handler. Hope this helps. Regards, Scott Rossi Creative Director Tactile Media, UX Design Recently, John Patten wrote: > Hi All... > > I'm trying to get my head around the idea of using repeated loop to > animate objects. These are probably pretty basic concepts, but I feel > I need to get some basic understanding on things such as interrupting > a loop, etc. > > For example, > > On a card there's a graphic object, a field and a button. The button > contains the following script: > > on mouseUp > if cd fld 1 is "True" then > moveTheBall > put "false" into cd fld 1 > else > put "True" into cd fld 1 > > end if > end mouseUp > > > on moveTheBall > --put the loc of grc 1 into tCurrentBallLoc > repeat 20 > add 10 to item 2 of tCurrentBallLoc > move grc 1 to tCurrentBallLoc > wait 25 milliseconds > if cd fld 1 is "false" then > exit moveTheBall > end if > end repeat > end moveTheBall > > This animates the graphic object however my means to interrupt the > loop don't quite cut it as the trigger doesn't get implemented until > after the command. > > What would be the proper way to interrupt a repeat? Anybody of some > simple examples of animating objects via loops? > > Thank you! > > John Patten > SUSD > > > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode