all groups > flash actionscript > august 2004 >
You're in the

flash actionscript

group:

Infinite loop problem with slideshow



Infinite loop problem with slideshow thomasperfecto
8/31/2004 10:19:59 PM
flash actionscript: Hi
I have a problem with a slideshow I've made. It works fine untill I call the
script again and then I get an error telling me
"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."
Can anyonw tell me how I can avoid this?

Here's the code...



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._width
[quoted text, click to view]
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)
}

this.createEmptyMovieClip("myImage",4);

myImage.onLoad = function() {
var maxWidth = 900;
var maxHeight = 670;

if (this._width>maxWidth || this._height>maxHeight)
{
var scaleFactor = this._width>this._height ? maxWidth/this._width :
maxHeight/this._height;
this._width = Math.floor(this._width*scaleFactor);
this._height = Math.floor(this._height*scaleFactor);
}
}

myImage.onData = function() {
}

myImage._alpha=0;

mypic=1;
_root.onEnterFrame = function()
{
if (myImage._alpha <10)
{
myImage.loadMovie("maspalomas/image"+mypic+".jpg", "myImage")
fadeOut=false;
fadeIn=true;
message.text = mypic; }
}
if (myImage._alpha > 10 && fadeOut)

{
myImage._alpha -= 10;

}

if (myImage._alpha < 100 && fadeIn && !fadeOut)
{
myImage._alpha += 10;
}
else
{
fadeIn=false;
}

}

next.onPress = function()
{
if( mypic < 10 && !fadeIn && !fadeOut)
{
fadeOut=true;
mypic++;
}
if(mypic >= 10)
{
mypic=1;
}
}
back.onPress = function()
{
if (mypic > 1 && !fadeIn && !fadeOut)
{
fadeOut = true;
mypic--;
}
if (mypic == 1 && !fadeIn && !fadeOut)
{
fadeOut=true;
mypic=10;
}
}


{
autoAdvance();
setInterval(autoAdvance, 10000)
}
function autoAdvance()
{
if (mypic <= 10 && !fadeIn && !fadeOut)
{
fadeout=true;
mypic++;
}
if (mypic > 10)
{ mypic=1;
}
if (mypic == 10)
{
_root.gotoAndStop("map");
}
}
Cheers
Re: Infinite loop problem with slideshow David Stiller
9/1/2004 9:33:21 AM
[quoted text, click to view]


Well ... leave out that line. :)

You pasted a whole lot of code, most of which works, you said. That's
already a good thing. :) Next, since you know which line offends, remove
it. "Ah," you say, "but it *needs* to call itself! It needs to repeat
until finished!"

The "until finished" is your key, then. You must find a way for that
line to know when it's done, rather than call itself ad nauseam.


David
stiller ( at ) quip ( dot ) net

Re: Infinite loop problem with slideshow thomasperfecto
9/1/2004 9:33:52 AM
I know the problem is

this.oldLoadMovie(url,vars)

AddThis Social Bookmark Button