File: ? Attempt to index field 'contentBounds' (a nil value)

what does this mean?

in error here is the full stack traceback error

Corona Simulator Runtime error

File: ?

Attempt to index field ‘contentBounds’ (a nil value)

stack traceback:

?: in function ‘_saveSceneAndHide’

?: in function ‘gotoScene’

MainMenu.lua:979: in function <MainMenu.lua:969>

?: in function <?:218>

?: in function ‘_saveSceneAndHide’

?: in function ‘gotoScene’

MainMenu.lua:979: in function <MainMenu.lua:969>

?: in function <?:218>

?: in function ‘_saveSceneAndHide’

?: in function ‘gotoScene’

MainMenu.lua:979: in function <MainMenu.lua:969>

?: in function <?:218>

?: in function ‘_saveSceneAndHide’

?: in function ‘gotoScene’

TopLevelMenu.lua:241: in function <TopLevelMenu.lua:230>

?: in function <?:218>

It means that you need to look at your code!

Somewhere contentBounds = nil - so your code is breaking because of this => problem is something to do with a variable ‘contentBounds’

It gives you  function names & line numbers and scene.luas (all information to help you track the problem or traceback ( problem then step backwards) - which means “hey i was trying to do this when your code broke - so the problem is here somewhere”

I’m sorry if this sounds curt, but with what you posted in your request - this is the best answer that you will get.

Anything more will require code - ( that is associated with ‘contentBounds’ - and that is just an educated guess based on the info you posted!)

T.

Nevermind already fixed it, I don’t have any contentBounds variable, I was hoping it was an composer variable thing

It means that you need to look at your code!

Somewhere contentBounds = nil - so your code is breaking because of this => problem is something to do with a variable ‘contentBounds’

It gives you  function names & line numbers and scene.luas (all information to help you track the problem or traceback ( problem then step backwards) - which means “hey i was trying to do this when your code broke - so the problem is here somewhere”

I’m sorry if this sounds curt, but with what you posted in your request - this is the best answer that you will get.

Anything more will require code - ( that is associated with ‘contentBounds’ - and that is just an educated guess based on the info you posted!)

T.

Nevermind already fixed it, I don’t have any contentBounds variable, I was hoping it was an composer variable thing

Hi, I’m having the same problem :frowning: How did you solve the problem? Thank you.

Display objects have a variable named contentBounds.

I.e. myDisplayObject.contentBounds. its a table. If your checking the content bounds of an object ex myDisplayObject.contentBounds.xMin … And you remove the display object, but are still checking against that variable, then you are attempting to index a nil value

Hi :slight_smile: Thank you very much for your reply. Actually I don’t have any contentBounds word on my code. I searched for that word everywhere and didn’t find anything. I’m using the Composer library. I really don’t know how to fix this. I just edited the Composer sample code and deleted everything except the essential event functions. It works when I go to Scene1, but not from Scene1 to Scene2 :frowning: If I do start from Scene2 when the app starts, it works, but not from scene to scene transition.

Are you using any widgets?

>> _saveSceneAndHide

this function is in Composer, and it’s inside this function that your error is occurring.

that function likely remains the same as it was in storyboard, and there is some “unguarded” code in there that can attempt to access currentScene.contentBounds even after the scene’s displayGroup (aka view) had been removed.  (which would cause exactly the error you’re seeing - once the scene’s view is disposed it ceases to have a .contentBounds property)

the Composer demo is designed to only cycle in forward order:  1,2,3,4, repeat.  Each scene has code that removes the “prior” scene during that scene’s show() event.  My guess is you’ve left that existing forward-only code, but changed the order, so scenes are being removed in an inconsistent order, and *during* the transition.

hth

Hi :wink: Thank you very much for all your help. I managed to solve it. Just a little misarrangement of the functions :slight_smile: Thank you.

Hi, I’m having the same problem :frowning: How did you solve the problem? Thank you.

Display objects have a variable named contentBounds.

I.e. myDisplayObject.contentBounds. its a table. If your checking the content bounds of an object ex myDisplayObject.contentBounds.xMin … And you remove the display object, but are still checking against that variable, then you are attempting to index a nil value

Hi :slight_smile: Thank you very much for your reply. Actually I don’t have any contentBounds word on my code. I searched for that word everywhere and didn’t find anything. I’m using the Composer library. I really don’t know how to fix this. I just edited the Composer sample code and deleted everything except the essential event functions. It works when I go to Scene1, but not from Scene1 to Scene2 :frowning: If I do start from Scene2 when the app starts, it works, but not from scene to scene transition.

Are you using any widgets?

>> _saveSceneAndHide

this function is in Composer, and it’s inside this function that your error is occurring.

that function likely remains the same as it was in storyboard, and there is some “unguarded” code in there that can attempt to access currentScene.contentBounds even after the scene’s displayGroup (aka view) had been removed.  (which would cause exactly the error you’re seeing - once the scene’s view is disposed it ceases to have a .contentBounds property)

the Composer demo is designed to only cycle in forward order:  1,2,3,4, repeat.  Each scene has code that removes the “prior” scene during that scene’s show() event.  My guess is you’ve left that existing forward-only code, but changed the order, so scenes are being removed in an inconsistent order, and *during* the transition.

hth

Hi :wink: Thank you very much for all your help. I managed to solve it. Just a little misarrangement of the functions :slight_smile: Thank you.