Im writing a scrambling text proto and its working fine, but I can't seem to kill the interval if I want it to stop before its finished.
How do I get to the interval obj?
thanks
-joe
Code:
TextField.prototype.clearWrite = function() {
clearInterval(itv);
this.html ? this.htmlText="" : this.text="";
};
TextField.prototype.XWrite = function($text, $milliseconds) {
var THIS = this;
var i = 0;
this.html ? this.htmlText="" : this.text="";
this._visible = false;
this.text = $text;
!this.multiline && this.textWidth>this._width ? this._width=this.textWidth+3 : null;
this.html ? this.htmlText="" : this.text="";
this._visible = true;
this.itv = setInterval(function () {
var ts = "";
var al = "!@#$%^&*()_-123467890~=".split("");
for (var s = 1; s<=$text.length-i; s++) {
ts += al[random(al.length)];
}
!THIS.html ? THIS.text=$text.substring(0, i)+ts : THIS.htmlText=$text.substring(0, i)+ts;
i++;
if (i>$text.length) {
clearInterval(THIS.itv);
}
updateAfterEvent();
}, $milliseconds != undefined ? $milliseconds : 20);
};
// USEAGE
write.onPress = function() {
myTXT.XWrite("<font color='#FF0000'>I knew a man</font> from spain with a top hat, <font size='19'>specs, and a cane</font>");
};
erase.onPress = function() {
myTXT.clearWrite();
};