how to to make a volatile value a persistent value ?

hi, in the code below, i can’t have acces to result because the two value are volatile and is not persistent.

is there a way to have a persistent value for two to make the last operation result  ? i must say that in the future i must have access to result, so result must be also persistent.

local rectangle = display.newRect(200,200,300,300) rectangle.xScale=1 rectangle.yScale=1 transition.scaleBy(rectangle, {tag=rectanglefall, time=1000, yScale=-1 , xScale=-1}) one= rectangle.xScale timer500 = function()     two=rectangle.xScale end timer.performWithDelay( 500, timer500) result=two-one print(result)

Nobody ?

You can’t access the result there, because the function has not been executed yet.

What you could do is have a loop (timer) that checks the state of the variable “result” and cancels after the value is not nil.

Or you could have a runtime listener that handles this kind of stuff, or better yet … dispatch an event to a listener (the best way imho) when the timer has finished, so you can then get access to result.

i.e:

local function resultListener( event )     print( event.result ) end   Runtime:addEventListener( "resultEvent", resultListener );   -- In your timer code: Runtime:dispatchEvent( { name = "resultEvent", result = two-one } );

ok thanks for the response.

have a nice day !

Nobody ?

You can’t access the result there, because the function has not been executed yet.

What you could do is have a loop (timer) that checks the state of the variable “result” and cancels after the value is not nil.

Or you could have a runtime listener that handles this kind of stuff, or better yet … dispatch an event to a listener (the best way imho) when the timer has finished, so you can then get access to result.

i.e:

local function resultListener( event )     print( event.result ) end   Runtime:addEventListener( "resultEvent", resultListener );   -- In your timer code: Runtime:dispatchEvent( { name = "resultEvent", result = two-one } );

ok thanks for the response.

have a nice day !