Help With Transition Please!

Hi! I’m having a problem with transition.pause()

local square = display.newRect( 0, 0, 100, 100 ) local w,h = display.stageWidth, display.stageHeight local function onPause() transition.pause(transition1) end local transition1 = transition.to( square, { time=10000, alpha=0, x=(w-50), y=(h-50)} ) Runtime:addEventListener('tap', onPause)

When I run this and tap on the screen, this error message pops up:

“Attempt to call field ‘pause’ (a nil value)”

I can’t see where the problem is. The code is pretty simple. Can someone please help me understand? I have read http://docs.coronalabs.com/api/library/transition/pause.html but can’t seem to find the answer. Thank you! 

transition1 is not seen by the onPause function.

You need to move the transition.to statement above the onPause function, or at least define the variable above the function

local transition1 = nil   local function onPause()     transition.pause(transition1) end   transition1 = transition.to( square, { time=10000, alpha=0, x=(w-50), y=(h-50)} )

Hi schizoid2k. Thank you very much for your reply. I have tried to do as you’ve told me. But the same error message comes up.

I just copied that bit of code to a test file on my system and ran it without any problem.

I would check your code… is there another onPause somewhere, for example.  I now see that the original error was onPause was nil (not transition1 like I originally thought)

Wow this is weird, I’m still having the same error message all the time. There is no onPause anywhere else. Thats basically all the code in it. I’m so confused. Any clues?

This is the rest of the error message if it helps:

stack traceback:

    [C]: in function ‘pause’

    …/Desktop/Projects/One/Test/main.lua:8: in function

<…/Desktop/Projects/One/Test/main.lua:6>

    ?: in function <?:218>

I’m a bit stumped myself… what build are you using?  I am using build 2013.2097 and I literally copied/pasted your code into a new main.lua file and ran it without issue.  The only messages I received are the 2 warnings below.

WARNING: display.stageWidth has been deprecated. Use display.contentWidth instead WARNING: display.stageHeight has been deprecated. Use display.contentHeight instead

I also ran it in Graphics 2.0 and 1.0 modes without any difference.

My Corona Project Manager is version 3.0.4 (5)

My Corona Simulator is version 2013.1137 (2013.6.7)

Do I have an outdated version of one of them? Can I update versions with a starter account? If so, how do I do it?

Ok you might think I’m the stupidest person on the planet after this. I uninstalled my old version and downloaded the latest (I think) starter version (2013.2076)…rerun the program and works perfectly. I guess the library was not updated in the old version. Thanks for all the help schizoid2k!

Great!  Glad it is working.  I have to admit, I was a bit stumped at this point.  :slight_smile:

transition1 is not seen by the onPause function.

You need to move the transition.to statement above the onPause function, or at least define the variable above the function

local transition1 = nil &nbsp; local function onPause() &nbsp; &nbsp; transition.pause(transition1) end &nbsp; transition1&nbsp;=&nbsp;transition.to(&nbsp;square,&nbsp;{&nbsp;time=10000,&nbsp;alpha=0,&nbsp;x=(w-50),&nbsp;y=(h-50)}&nbsp;)

Hi schizoid2k. Thank you very much for your reply. I have tried to do as you’ve told me. But the same error message comes up.

I just copied that bit of code to a test file on my system and ran it without any problem.

I would check your code… is there another onPause somewhere, for example.  I now see that the original error was onPause was nil (not transition1 like I originally thought)

Wow this is weird, I’m still having the same error message all the time. There is no onPause anywhere else. Thats basically all the code in it. I’m so confused. Any clues?

This is the rest of the error message if it helps:

stack traceback:

    [C]: in function ‘pause’

    …/Desktop/Projects/One/Test/main.lua:8: in function

<…/Desktop/Projects/One/Test/main.lua:6>

    ?: in function <?:218>

I’m a bit stumped myself… what build are you using?  I am using build 2013.2097 and I literally copied/pasted your code into a new main.lua file and ran it without issue.  The only messages I received are the 2 warnings below.

WARNING: display.stageWidth has been deprecated. Use display.contentWidth instead WARNING: display.stageHeight has been deprecated. Use display.contentHeight instead

I also ran it in Graphics 2.0 and 1.0 modes without any difference.

My Corona Project Manager is version 3.0.4 (5)

My Corona Simulator is version 2013.1137 (2013.6.7)

Do I have an outdated version of one of them? Can I update versions with a starter account? If so, how do I do it?

Ok you might think I’m the stupidest person on the planet after this. I uninstalled my old version and downloaded the latest (I think) starter version (2013.2076)…rerun the program and works perfectly. I guess the library was not updated in the old version. Thanks for all the help schizoid2k!

Great!  Glad it is working.  I have to admit, I was a bit stumped at this point.  :slight_smile: