Skip to main content
Inspiring
April 21, 2012
Question

addChild Crashing iPad3 [HELP]

  • April 21, 2012
  • 1 reply
  • 411 views

I have an application that has 8 buttons on an interface. Each button loads a movie clip from the library.

The way I'm doing it now .. is I am putting 8 variables when the app load up.

var movieclip1;
var movieclip2;
var movieclip3;
var movieclip4;
var movieclip5;
var movieclip6;
var movieclip7;
var movieclip8;

When the user clicks on a button I am doing the MovieClip = new MovieClip(); method .. when the user exits that section I am setting the movie clip to null and removing it.

I am finding though that I am having some memory problems on the iPad3 doing it this way.

Is there a better way I could be doing this ?

Id like it so when you aren't in a loaded section .. there is nothing at all in the memory for that section.  What I'm doing now is ... if you click on Button1 and load up movieclip1 ...  and then you click button 2...   it will check if any of the 8 movieclips are loaded... if they are .. they are removed and set to null

However the dilemma I face... is that tweening always performs sluggish the first time around if that movie clip hasn't been previously added to the stage. Once it performs the tween once .. then its fine.

I'm hoping there is a better way to handle these movie clips.

Another question i have...   one of the movieclips has 48 seperate MouseEvent listeners. ...   when I remove and NULL the movieclip ...   do I need to manually remove each mouse event listener ?   I've read that listeners dont get destroyed.   Could it be these listeners that are building up and causing the crashing on the iPad3 ?   It doesnt crash on iPad2 .. and runs great on the desktop.

Trying to optimize this the best way possible.

Any help is appreciated.

This topic has been closed for replies.

1 reply

Inspiring
April 23, 2012

You can use a SINGLE MouseEvent listener attached to the main movieclip and handle it like:

function handleClick(e:Event):void{

     switch (e.target.name) {

          case 'a'...         

For safety, remove any listeners, stop sounds and timeline animations, dispose XML data (if any), call unloadAndStop(), then remove-child the loaded contents and null them.