Skip to main content
Participating Frequently
December 17, 2012
Question

256 Levels error.

  • December 17, 2012
  • 1 reply
  • 763 views

So I am reskining a purchased game for a client and now this appears every time i click on an enemy.

256 levels of recursion were exceeded in one action list.

This is probably an infinite loop.

Further execution of actions has been disabled in this movie.

Thing is I haven't changed any of the code really just delete the unnessarcy items & animations that aren't being used.

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
December 17, 2012

You should show the code that might be related to an infinite loop if you can identify it.  If the is not alot of code, show it all.

vekzeroAuthor
Participating Frequently
December 17, 2012

Ok so here is the code I feel like it has something to do with the bottle and moving bottle code...

I bolded what I think is causing the problem but I can't figure out how to fix it...

import mx.transitions.Tween;

import mx.transitions.easing.*;

import flash.filters.BlurFilter;

//function for hitting coconut

function shotCoconut(targetX:Number, targetY:Number,target:MovieClip) {

          _global.CocoCnt++;

          coconutShot_mc.duplicateMovieClip("coconutShot_mc"+_global.CocoCnt, _global.CocoCnt+100);

          var coco:MovieClip = eval("coconutShot_mc"+_global.CocoCnt);

          coco._alpha = 100;

          coco._x = 170.2;

          coco._y = 241.2;

          var filter:BlurFilter = new BlurFilter(0, 10, 2);

          coco.filters = new Array(filter);

          var tween_handler:Object = new Tween(coco, "_x", Strong.easeOut, 170.2, targetX, 10,false);

          new Tween(coco, "_y", Strong.easeOut, 241.2, targetY, 1, true);

          new Tween(coco, "_xscale", Strong.easeOut, 100, 30, 1, true);

          new Tween(coco, "_yscale", Strong.easeOut, 100, 30, 1, true);

          tween_handler.onMotionFinished = function() {

                    //trace("onMotionFinished triggered");

                    new Tween(coco, "_alpha", Strong.easeOut, 100, 0, 1,false);

                    if(!target.hit){

                              target.hit = true;

                              breakGlass(target);

                    }

          };

}

function moveBottle(obj:MovieClip){

          //18 to 366

          var tween_handler:Object = new Tween(obj, "_alpha", Strong.easeOut, 0, 100,0.1,true);

          obj._x = 2+ random(350);

          checkCollision(obj)

          tween_handler.onMotionFinished = function() {

                    //trace("onMotionFinished triggered");

                    obj.hit = false;

                    trace(obj)

          };

}

function checkCollision(obj:MovieClip){

          var bol:Boolean = false;

          for(i=1;i<=4;i++){

                    if(obj._name != "whine"+i+"_mc"){

                              var mov:MovieClip = eval("whine"+i+"_mc");

                              bol = obj.hitTest(mov);

                              if(bol){

                                        moveBottle(obj);

                                        break;

                              }

                    }

          }

}

function hitTheBottle(obj:MovieClip) {

          if(obj._name=="blank_mc"){

                    shotCoconut(_xmouse, _ymouse);

          }else{

                    shotCoconut(obj._x, obj._y+5,obj);

          }

}

function breakGlass(obj:MovieClip) {

          obj.gotoAndPlay("_break");

          //place score update

          score_txt.text = _global.score;

}

//hitting nowhere

blank_mc.onPress = function() {

          hitTheBottle(this);

};

//Hitting the bottles

whine1_mc.onPress = function() {

          hitTheBottle(this);

          _global.score += 5;

};

whine2_mc.onPress = function() {

          hitTheBottle(this);

          _global.score += 5;

};

whine3_mc.onPress = function() {

          hitTheBottle(this);

          _global.score += 5;

};

whine4_mc.onPress = function() {

          hitTheBottle(this);

          _global.score += 5;

};

//SET TIMER

function startInt(){

          timeInt = setInterval(this,"displayTime",1000);

}

function displayTime(){

          var m = "";

          var s = "";

          var h = "";

          if(_global.secs < 0){

                    _global.secs = 59;

                    _global.mins--;

          }

          if(_global.secs < 10){

                    s = "0"+ String(_global.secs);

          }else{

                    s = String(_global.secs);

                    }

          if(_global.mins < 10){

                    m = "0"+ String(_global.mins);

          }else{

                    m = String(_global.mins);

                    }

          if(m==0 && s==0){

          //this pertains to a game over

                    _global.GameOver();

                    clearInterval(timeInt);

          }

          //temporarily setting hour to zero, but we may modify to add variable hour later

          h="00";

          this.timer_txt.text = m + ":" + s;

          //reduce 1 second if _global.pauseTime is false;

          //else you wait til firemen extinguishes the level1 and 11 fire

          if(!_global.pauseTime){

                    _global.secs--;

          }

          if(_global.secs==0 && _global.mins==0){

                    this.gotoAndStop('_gameOver')

          }

          _global.checkTime();

}

function clearInt(){

          clearInterval(timeInt);

}

startInt();

stop();

Inspiring
December 18, 2012

It seems like indirect recursion where you are calling another function from another which then calls the previous function and so on and so forth. See how moveBottle() is called in checkCollision() and vice versa, meaning they loop seemingly infinitely. You could do similar things with recursion using for loops instead, without the 256 level error.