I need to call a function every number of seconds or so… I’ll just show some code:
image0.folder = "folder1/";
image1.folder = "folder2/";
image2.folder = "folder3/";
textholder._alpha = 0;
var whichIsText:Number;
var interval:Number;
this.onRelease = function(){
interval = 2000;
changeText();
}
function changeText() {
chooseRandom();
showTxt();
}
function chooseRandom() {
whichIsText = Math.floor(Math.random()*3);
//trace (whichIsText);
}
function showTxt() {
textholder.onEnterFrame = function() {
if (textholder._alpha<1) {
if (whichIsText == 0) {
textholder._x = image0._x;
} else if (whichIsText == 1) {
textholder._x = image1._x;
} else if (whichIsText == 2) {
textholder._x = image2._x;
} else {
trace("error");
}
textholder.fadeIn();
}
hideTxt();
};
}
function hideTxt() { //the interval function
var wait = setInterval(hide,interval);
}
function hide(){
textholder.fadeOut();
}
MovieClip.prototype.fadeIn = function() {
this.onEnterFrame = function() {
this._alpha += 10;
if (this._alpha>99) {
delete this.onEnterFrame;
//trace("asd");
}
};
};
MovieClip.prototype.fadeOut = function() {
this.onEnterFrame = function() {
this._alpha -= 10;
if (this._alpha<1) {
//trace("asd213");
delete this.onEnterFrame;
}
};
};
basically, what it does is when i click, a block box (textholder), fades in, then after a few seconds (in this case, 2), it fades out again… it works fine on the first click, but after more clicks, the interval duration seems to be getting smaller, up to a point where it is zero, and nothing happens.
and I need to use another setInterval() function (to call the changeTxt() function), will that affect the setInterval function i have up there now?
i’ve linked an swf, to better show what i mean.
http://img142.imageshack.us/img142/1240/header3cb1.swf