I filed a bug report (Case 34276) for the issue with transition.cancel() acting strangely when you supply the variable for a display object as the argument. I didn’t discover this thread until afterwards, so it would seem that the problem is larger in scope than I originally thought. Anyways, here’s the description I gave in my bug report:
Starting with daily build # 2014.2365, calling transition.cancel() with a display object as the sole argument results in unwanted behavior. The transition successfully cancels, but future attempts to perform a transition to that display object are unsuccessful, with no error outputted to the terminal. I have confirmed that this bug first presented itself in daily build # 2014.2365, up to and including the most recent daily build as of today (#2014.2373). Using transition.cancel() while supplying a handle or tag instead of a display object as the argument works as expected in my testing - this issue seems to be isolated to cases where you supply the a display object’s variable as the argument.
See the attached main.lua, which has buttons to perform the following:
1.) start a transition on the rectangle in the center of the screen
2.) cancel that transition, supplying the rectangle’s variable as the sole argument to transition.cancel()
3.) re-start the transition.
4.) repeat steps 2 & 3 as often as you want.
Using daily build # 2014.2365 or earlier, this little program works as you’d expect. But starting with build # 2014.2365, step 3 above does not work.
And here is the main.lua file I supplied as a test case:
------------------------------------------------------------------------------------ -- REQUIRE WIDGET LIBRARY ------------------------------------------------------------------------------------ local widget = require("widget") ------------------------------------------------------------------------------------ -- DELARE POSITIONING VARIABLES ------------------------------------------------------------------------------------ local centerX = display.contentCenterX local centerY = display.contentCenterY local screenTop = display.screenOriginY local screenLeft = display.screenOriginX local screenBottom = display.screenOriginY+(display.contentHeight-(display.screenOriginY\*2)) local screenRight = display.screenOriginX+(display.contentWidth-(display.screenOriginX\*2)) local screenWidth = screenRight - screenLeft local screenHeight = screenBottom - screenTop ------------------------------------------------------------------------------------ -- FORWARD DELARE VARIABLES ------------------------------------------------------------------------------------ local rect, goTrans, buttonPress, button1, button2, button3 function goTrans() local targetY = centerY - screenHeight\*.25 if rect.y ~= centerY then targetY = centerY end transition.to(rect, {y = targetY, transition = easing.inOutSine, onComplete = goTrans}) end rect = display.newRect(centerX, centerY, screenWidth\*.25, screenWidth\*.25) function buttonPress(event) local target = event.target if target.pressed == nil then target.pressed = true transition.to(target, {alpha = 0, y = screenBottom}) if target == button1 then goTrans() transition.to(button2, {alpha = 1, y = centerY + screenHeight\*.25}) elseif target == button2 then transition.cancel(rect) transition.to(button3, {alpha = 1, y = centerY + screenHeight\*.25}) button3.pressed = nil elseif target == button3 then goTrans() transition.to(button2, {alpha = 1, y = centerY + screenHeight\*.25}) button2.pressed = nil end end return true end button1 = widget.newButton({ label = "start transition", shape = "roundedRect", fontSize = screenWidth\*.08, width = screenWidth \* .75, height = screenHeight \* .1, onRelease = buttonPress }) button1.x, button1.y = centerX, centerY + screenHeight\*.25 button2 = widget.newButton({ label = "cancel transition", shape = "roundedRect", fontSize = screenWidth\*.08, width = screenWidth \* .75, height = screenHeight \* .1, onRelease = buttonPress }) button2.x, button2.y = centerX, screenBottom button2.alpha = 0 button3 = widget.newButton({ label = "re-start transition", shape = "roundedRect", fontSize = screenWidth\*.08, width = screenWidth \* .75, height = screenHeight \* .1, onRelease = buttonPress }) button3.x, button3.y = centerX, screenBottom button3.alpha = 0