runtime event crash

I’m trying to figure out how to remove the follow event:

function clean ( event )  
 Runtime:removeEventListener( "enterFrame", moveCamerax )  
 Runtime:removeEventListener( "enterFrame", moveCameray )  
end  

If I remove the event listener there my program crashes. So, where do I remove it? [import]uid: 15663 topic_id: 6850 reply_id: 306850[/import]

Remove it when you are no longer using it.

Ie when changing back to the menu or such [import]uid: 6981 topic_id: 6850 reply_id: 24036[/import]

Just before your changeScene ie

Runtime:removeEventListener( “enterFrame”, moveCamerax )
Runtime:removeEventListener( “enterFrame”, moveCameray )
director:changeScene(“NextScene”) [import]uid: 8366 topic_id: 6850 reply_id: 24076[/import]

Actually, it wasn’t a runtime error… For some reason Director doesn’t like changing scenes without a transition effect unless it’s the main.lua file.
I switched the code from this:

director:changeScene("levelSelect")  

to this:

director:changeScene("levelSelect", "fade")  

And it ran fine. Any idea’s why Director did this? [import]uid: 15663 topic_id: 6850 reply_id: 24209[/import]

It may be because without a transition it changes too fast?

Are you using the latest Director (1.2)? Where I think this has been fixed (see 3 below).

Release Info for 1.2 follows, taken from this thread:

http://developer.anscamobile.com/forum/2011/02/02/any-idea-when-v12-might-come-out
All the major updates were at the memory management and cleaning scenes.

1 - Now you don’t need to modify Director to use the clean function, Director will search for it and if it find then will execute it.

2 - Cleaning scenes are divided in 3 steps:
2.1 - Execute the clean() function if it exists
2.2 - Remove all display objects inserted into the localGroup
2.3 - Unload the module and call the garbage collector

3 - I added a “safe time delay” to start transitions without crashing.

4 - You can change the effects time and safe delay via programming.

5 - There are 3 new transitions on changeScene:
5.1 - moveFromTop
5.2 - moveFromBottom
5.3 - crossfade

6 - A lot of people asked me about changing scenes like a book. I tryed to do it on this version but it is very hard to do. So, I put on the sample a little slider to see how to use moveFromLeft and moveFromRight to feel like a book.

7 - All the files on the sample are better structured and have the initVars() function to show how to start your variables values and use it on a pause or restart function.

8 - There is a boolean variable to prevent change scenes while it’s still changing a scene. [import]uid: 8366 topic_id: 6850 reply_id: 24212[/import]

I’m using version 1.2 but I think your right about the scene change happening to fast with no transition effect. I looked through the code for director (1.2) and found this code applies to a scene change with no transition effect:

-----------------------------------  
-- EFFECT: None  
-----------------------------------  
  
else  
 timer.performWithDelay( 0, fxEnded )  
 loadScene (newScene)  
end  

Now, I’m not an experienced programmer but I don’t think there is a “safe time delay” for a scene change with no effect, which means there may not be enough of a delay with no transition effect. Either way thanks for the help figuring out the problem. [import]uid: 15663 topic_id: 6850 reply_id: 24213[/import]

I had a similar issue… I don’t specify an effect in my transitions and, on occasion, my app would crash during a transition between two screens (modules). Now to be fair… I would have to work at crashing it by rapidly changing back and forth between screens but it would happen. I added the safeDelay time to the code in the above post and it greatly reduced the crashing. I then doubled the time and it appears to have eliminated all crashing. Of course this may all be coincidence but the addition of time appears to have had a beneficial affect. [import]uid: 16901 topic_id: 6850 reply_id: 25348[/import]

Just as a followup… I wasn’t using the clean function correctly which created a race condition that was helped by the delay. Of course, correctly using clean allowed me to remove the delay and still have perfect operation. [import]uid: 16901 topic_id: 6850 reply_id: 28141[/import]

The only way you can guarantee no crashing between rapid screen transitions (ie tapping menu then back as fast as possible). is to remove your active listeners on touch then delay adding your touch listeners for the next scene by 3 times the fx delay.

I had to do that, and it removed all crashing. And the timing is perfect so as soon as the scene has actually finished transitioning the buttons are usuable, but not before.

That fixed the issue for me [import]uid: 6981 topic_id: 6850 reply_id: 28305[/import]

infuseddreams , would u please clarify what you wrote, I got confused,

I have more than one add listener so how can I make all of them 3 times of fx delay ? [import]uid: 13061 topic_id: 6850 reply_id: 30544[/import]