How to control a scrollView in a composer scene from main.lua ?

Hello,

how can I control a scrollView in a composer scene from mail.lua?

I want to stop the scrollView using  scrollView:setIsLocked() .

I tried to access the scrollView via  composer.getScene()  as written in the example here

https://docs.coronalabs.com/api/library/composer/getScene.html, but it didn’t work. 

Any help appreciated!

You can just create a global reference to it. It isn’t recommend to have too many globals in the app, unless they are properly managed.

Just do this :

local scrollView = --Your scrollview object here global\_scrollView = scrollView -- Now you can access it with 'global\_scrollView' anywhere in the app.

The way we would suggest you do this would be to setup up a custom event and then from main.lua, dispatch the event and that would trigger code in your scene where you have an in-scope reference to the scrollView.

The global is easy.  The event system is more work.  Also consider:

http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/

In this case, you eliminate global issues by using a data table that holds the reference to your scrollView in a module that just gets included everywhere. Globals without the issues of globals!

Rob

You can just create a global reference to it. It isn’t recommend to have too many globals in the app, unless they are properly managed.

Just do this :

local scrollView = --Your scrollview object here global\_scrollView = scrollView -- Now you can access it with 'global\_scrollView' anywhere in the app.

The way we would suggest you do this would be to setup up a custom event and then from main.lua, dispatch the event and that would trigger code in your scene where you have an in-scope reference to the scrollView.

The global is easy.  The event system is more work.  Also consider:

http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/

In this case, you eliminate global issues by using a data table that holds the reference to your scrollView in a module that just gets included everywhere. Globals without the issues of globals!

Rob