OK on my main timeline i have 2 buttons each one loading 2 seperate SWF’s. When I load the first SWF it works perfect. Now when I load the other SWF. on the same level it replaces the 1st SWF. Now comes the problem, when i go to reload the first SWF the error accurs. [COLOR=red]“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.”[/COLOR]
I understand the concept of the error. I just can not fix it. Is it a matter of having everthing on one SWF. file. Or is there an unloadMovie script I can use.
I found this script from Actionscript.org. Posted it there…but didn’t get ther help i needed. Here is the script that i am loading into the main FLA. Any help would be greatly appricated. thanks
Movieclip.prototype.oldLoadMovie = Movieclip.prototype.loadMovie;
Movieclip.prototype.loadMovie = function(url, vars) {
if (this.onData != undefined && this.onData != null) {
this._parent.createEmptyMovieClip("__fixEvents", 7777);
this._parent.__fixEvents.theTarget = this;
this._parent.__fixEvents.onData = this.onData;
if (this.onLoad != undefined && this.onLoad != null) {
this._parent.__fixEvents.onLoad = this.onLoad;
}
this._parent.__fixEvents.onEnterFrame = function() {
this.oldv = this.v;
this.v = this.theTarget.getBytesLoaded();
if (this.v != this.oldv) {
this.onData.call(this.theTarget);
}
if (this.v == this.theTarget.getBytesTotal()) {
this.theTarget.onData = this.onData;
if (this.onLoad != undefined) {
this.theTarget.onLoad = this.onLoad;
}
this.onLoad.call(this.theTarget);
this.removeMovieClip();
}
};
}
this.oldLoadMovie(url, vars);
};
// MovieClip growTo Proto v1 by Jesse Stratford
// [email]jesse@actionscript.org[/email]
// You may use this script as you wish provded these comments remain
// Arguments:
// w - target width
// h - target height
// growRate - higher = slower
// callback - funtion to call when growing is complete
MovieClip.prototype.growTo = function(w, h, growRate, callback) {
// If the grow rate is undefined or invalid, set it
if ((growRate == undefined) or (growRate<=0)) {
growRate = 20;
}
// Only grow if currently not growing
if (!this.growing) {
this.growing = true;
// Call doGrowTo at regular intervals (change the '60' below if you wish)
this.growInterval = setInterval(this, "doGrowTo", 40, w, h, growRate, callback);
} else {
// already growing, don't start again.
// might want to indicate some sort of error here
}
};
MovieClip.prototype.doGrowTo = function(w, h, growRate, callback) {
// Get the current width and heigh of the clip
wDiff = w-this._width;
hDiff = h-this._height;
// Inertia resize workaround. If we're within 2 pixels, snap to size.
if (Math.abs(wDiff)<2 && Math.abs(hDiff)<2) {
this._width = w;
this._height = h;
// Stop the grow interval (save CPU)
clearInterval(this.growInterval);
// Reset growing variable
this.growing = false;
// Call function if one was passed
if (callback) {
callback();
}
} else {
// Keep growing if we haven't reached our target size.
this._width += wDiff/growRate;
this._height += hDiff/growRate;
}
};
// Actions for buttons
photo1_bttn.onRelease = function() {
loadThenGrow("image1.jpg");
};
photo2_bttn.onRelease = function() {
loadThenGrow("image2.jpg");
};
// LoadTheGrow function takes a target image name.
// Targets are hard-coded for the moment because I'm lazy
function loadThenGrow(img) {
bg_square_mc._parent.holder_mc.removeMovieClip();
bg_square_mc._parent.createEmptyMovieClip("holder_mc", 1);
bg_square_mc._parent.holder_mc._visible = false;
bg_square_mc._parent.holder_mc.onData = function() {
if (this.getBytesLoaded() == this.getBytesTotal()) {
this._visible = false;
// Image fully loaded, grab dimensions and resize
// background clip
w = this._width;
h = this._height;
bg_square_mc.growTo(w+10, h+10, 5, _root.showHolder);
}
};
bg_square_mc._parent.holder_mc.loadMovie(img);
}
function showHolder() {
w = bg_square_mc._parent.holder_mc._width;
h = bg_square_mc._parent.holder_mc._height;
bg_square_mc._parent.holder_mc._x = bg_square_mc._x-w/2;
bg_square_mc._parent.holder_mc._y = bg_square_mc._y-h/2;
bg_square_mc._parent.holder_mc._visible = true;
}
stop();
[EDIT by kode]Please use the ActionScript tag [AS][/AS] to show your code.[/EDIT]