Accessing parent scene function from overlay outside the original composer scene.

Code I post for example works but what I really want is to make a functions sequence to work after button pressed. I made a note in the code. How I can achieve that?

 
 

[lua]–Scene

–function outside scene

function scene:rearrange()
       --do something
end

–Overlay
–function outside scene

function scene:resume(a)
       a.rearrange()
end

function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then

       --NOTE. Widget button e.g (onRelease = scene:resume(event.parent))  

       scene:resume(event.parent)

end
[/lua]

That’s explained quite well here: https://docs.coronalabs.com/api/library/composer/showOverlay.html

What explained very well is how to get data from composer scene (create and show) using event.parent. What I am looking for is actually how to pass event.parent to a function outside composer scene through a widget button. Or maybe there is an option to pass parameters to a function without running it?

You can pass a reference to a function by simply stating:

local composer = require( "composer" ) local function printSomething() print( "something!" ) end composer.myFunction = printSomething -- Then you can call this anywhere you want as long as you've required composer in the file. composer.myFunction()

i.e. all you need is to add a reference to the function to some variable or table that is within scope of wherever you are trying to call the function from.

In the example at the docs, event.parent is scene, so having added a method to it like event:resumeGame() means that the function would be accessible anywhere where scene is accessible.

That’s explained quite well here: https://docs.coronalabs.com/api/library/composer/showOverlay.html

What explained very well is how to get data from composer scene (create and show) using event.parent. What I am looking for is actually how to pass event.parent to a function outside composer scene through a widget button. Or maybe there is an option to pass parameters to a function without running it?

You can pass a reference to a function by simply stating:

local composer = require( "composer" ) local function printSomething() print( "something!" ) end composer.myFunction = printSomething -- Then you can call this anywhere you want as long as you've required composer in the file. composer.myFunction()

i.e. all you need is to add a reference to the function to some variable or table that is within scope of wherever you are trying to call the function from.

In the example at the docs, event.parent is scene, so having added a method to it like event:resumeGame() means that the function would be accessible anywhere where scene is accessible.