Transition Cancel issue

Hi everyone
I am building a simple game app, and i have some like that:

i have a local transition, inside of a function, and have a button on the app to stop the transition,
and when i start the app, if i cancel the transition it gives me a nil value because the button dont detect any transition because the transition is inside of a local function, but if the transition already runed some time before and it is not running on this time, and i click on this button to stop the animation, it dont say nothing, it can cause any problems? i think that the button only should stop the transition when the transition is already running, when she is stopped i can cancel it every time, it can be dangerous to the app or cause problems?

Thanks [import]uid: 26056 topic_id: 22968 reply_id: 322968[/import]

can you post the code, might be easier to understand…:slight_smile: [import]uid: 118947 topic_id: 22968 reply_id: 91747[/import]

-- This is my button function  
 local stop\_touch = function( event )  
  
 if MyVar == true then  
 transition.cancel(Object5Transition)  
 end  
  
-- This is object 1 function collision   
  
local function Object1Collision( self, event )  
  
 if event.other.name == "Object5" then  
 MyVar = true  
 Object5Transition = transition.to(Object5, { time = 2000, alpha = 0 } )  
  
 local GT = function()  
 MyVar = false  
 end  
 transition.to(Object5, { time = 2100, onComplete = GT } )  
  
  
 end  
  
 Object1.collision = Object1Collision  
 Object1:addEventListener( "collision", Object1 )  
  

if cant understand tell me something, but i think that it is understandable. [import]uid: 26056 topic_id: 22968 reply_id: 91755[/import]

I might not have correctly understood what your question is at this point, but check out this article it has some best practices. It discusses the usage of a table (transitionStash), which you can use to add new transitions to and then cancel all of them at once.

Read the section Timers and Transitions:
http://blog.anscamobile.com/2011/08/corona-sdk-memory-leak-prevention-101/

Hope that helps,

–wunderwuzzi [import]uid: 118947 topic_id: 22968 reply_id: 91835[/import]