A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: 256 levels of recursion were exceeded...

  1. #1
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234

    256 levels of recursion were exceeded...

    Hey all,

    I'm working on a little drawing tool. The drawing area is made up of 400 MCs. I have written a 'fill' function but it keeps getting the '256 levels of recursion were exceeded' error. Below is the code, what am I doing wrong?
    It checks if the transform of the to be transformed MCs equals the transform of the first clicked MC. If so it tells that MC to preform the function. To no avail.

    Please help me out on this one. I'm going crazy here...

    Cheers,
    Hendricus

    Code:
    function fill() {
    	beforetransform = _root.beforetransform;
    	currentpx = name;
    	// checking the row of the clicked pixel
    	for (i=name; i>0; i=i-_root.numBlocksX) {
    		currentrow++;
    	}
    	pixels = ["px"+(currentpx)];
    	if (currentpx-_root.numBlocksX>0 && eval("_root.px"+(currentpx-_root.numBlocksX)+".canvas._alpha") == beforetransform) {
    		pixels.push("px"+(currentpx-_root.numBlocksX));
    	}
    	if (currentpx+_root.numBlocksX<_root.totalBlocks && eval("_root.px"+(currentpx+_root.numBlocksX)+".canvas._alpha") == beforetransform) {
    		pixels.push("px"+(currentpx+_root.numBlocksX));
    	}
    	for (i=currentpx-1; i>0; i=i-_root.numBlocksX) {
    		rowleftpx++;
    	}
    	for (i=currentpx+1; i>0; i=i-_root.numBlocksX) {
    		rowrightpx++;
    	}
    	if (rowleftpx == currentrow && eval("_root.px"+(currentpx-1)+".canvas._alpha") == beforetransform) {
    		pixels.push("px"+(currentpx-1));
    	}
    	if (rowrightpx == currentrow && eval("_root.px"+(currentpx+1)+".canvas._alpha") == beforetransform) {
    		pixels.push("px"+(currentpx+1));
    	}
    	for (i=0; i<pixels.length; i++) {
    		eval("_root."+pixels[i]+".canvas")._alpha = _root.alpha;
    		eval("_root."+pixels[i]).fill();
    	}
    }
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Posts
    384
    after a very quick look-
    you get that error after a function calls itself 256 times.
    so, sounds like you've got a problem with the path in that last line when you call eval("_root."+pixels[i]).fill();
    nosig\

  3. #3
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Well the problem is that the function calls itself (on other MCs) cause it needs to. It has to perform the same function within other MCs. And there's 20x20=400 MCs on stage...

    Is there a better solution?

    Cheers,
    Hendricus
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    if in MX use:
    this["_root."+pixels[i]+".canvas"]._alpha = _root.alpha;

    in other words, 'this' instead of 'eval'

    gparis

  5. #5
    Senior Member
    Join Date
    Mar 2001
    Posts
    384
    calling a function by the same name, in a different location is a different function and is not recursive.
    I don't have time to go through your script in any depth, but on this second glance my guess is that you're either failing to build the pixels array, or just filling it with the same pixel- which could produce that error- if the location specified is this pixel, it's calling itself.

    _root[pixels[i]].canvas._alpha
    nosig\

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center