Error using a Array of Loaders with externals SWFs, Camera and Gyroscope ANE
Hi all. Unfortunately I have no idea where could be problem.
I am developing an AR mobile game, currently only for Android, since I can not make the Gyroscope ANE to work in IOS 6.1.3, where no data is returned from the gyroscope (this may be other future post).
The game combines camera, gyroscope and dynamically add to the stage external SWFs. Each SWFs is loaded in a "Stuff" class that extends from Loader. I control its content from the main game class. And the Stuff class that extends from Loader has another objects properties as MovieClips, another Loader, and some TextFields and Sounds.
The game dinamically creates new Stuffs, add them to an Array, and when the player "beat" the Stuff, the Stuff is removed from the stage, each Stuff object is set to null, the Stuff is spliced from the Array and finally, System.gc() is used to recover all the memory. The maximum of Stuffs in the array (and in the stage) is 3. When the level is finished, all the objects are set to null (including the gyroscope and camera), the array is spliced and set to null too, garbage collector forced and when a new level is started all the variables/objects are set again.
The problem is this: independently of the level, sometime between 32 and 37 times that I add a new Stuff to the Array and to the stage, the game stops working. A "back" button on stage does not respond, and any action in the game is ignored. In that moment, the memory (measured with System.totalMemory/1024 and displayed on screen) leaks from a 4500/6500 to 11000, the camera keeps working as the background image and the only way to exit the app is killing it from a task manager.
Another strange thing is that every time I recreate the gyroscope object the it becomes "more sensitive", like the setInterval(100) only the first time is called sets that interval, and from the second that time it seems to be lower.
Any help will be very appreciated.
Thanks in advance.
