Composer "function scene:show( event )" not working properly?

Hi there,

I submitted the following as a bug (Case 29908),  but I just want to confirm that it is a bug and not me doing something wrong (if it is a bug I am happy to wait)…

Is show() working correctly? It appears that display objects added in show() are not correctly disposed of, I know display objects should be added in Create, but there are times when show() is needed (more dynamic content). If I add text in show() and then transition to another scene and back again it layers up. Is this the way it is supposed to work? Should I manually remove these objects in hide()?

The object, in this case text, is getting put into the sceneGroup (self.view) and transitions off the screen perfectly (so it must be in the group) – however when I transition back the text gets bolder and bolder as it layers up. 

I have attached my project files if anyone wants to test it out.

Craig

Just realised I did not attach the files :(…

Anyone able to help me out here?  Wondering if I should wait or recode my app in a different way.

Thanks in advance.

Craig

Hi Craig,

The “show” event is being called each time the scene is created and un-hidden, so you’re generating multiple text objects (just layering new ones atop the old ones). If you want to remove the old one, do so in the “hide > did” phase (I see you’ve done this, but commented it out). So basically, it’s true that you’re adding it properly to the scene’s view, but because of the scene event you’ve done this in (“show > will”, instead of “create”), you’re just making new objects over and over. This is not a bug, it’s just how the Composer scene concept works.

Hope this helps,

Brent

Thanks Brent,  

I wasn’t sure about this…  Up until now with storyboard I have just been purging the scene so it was not an issue… I am trying to be more efficient (and composer.removeScene( “myScene”, true ) is not working 100%) so I was not really sure how show (or enterScene) worked,  I just assumed anything added to self.view would be cleaned up…

I’ll go through my code and clean things up.

Thanks again,

Craig

Just realised I did not attach the files :(…

Anyone able to help me out here?  Wondering if I should wait or recode my app in a different way.

Thanks in advance.

Craig

Hi Craig,

The “show” event is being called each time the scene is created and un-hidden, so you’re generating multiple text objects (just layering new ones atop the old ones). If you want to remove the old one, do so in the “hide > did” phase (I see you’ve done this, but commented it out). So basically, it’s true that you’re adding it properly to the scene’s view, but because of the scene event you’ve done this in (“show > will”, instead of “create”), you’re just making new objects over and over. This is not a bug, it’s just how the Composer scene concept works.

Hope this helps,

Brent

Thanks Brent,  

I wasn’t sure about this…  Up until now with storyboard I have just been purging the scene so it was not an issue… I am trying to be more efficient (and composer.removeScene( “myScene”, true ) is not working 100%) so I was not really sure how show (or enterScene) worked,  I just assumed anything added to self.view would be cleaned up…

I’ll go through my code and clean things up.

Thanks again,

Craig