A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Help KILL my interval!

  1. #1
    ____________
    Join Date
    Sep 2004
    Location
    Hells Kitchen
    Posts
    191

    Help KILL my interval!

    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();
    };
    _

    __________________

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    can you stick the interval in _root? i've never had problems clearing intervals after i started sticking them all in _root.

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    you posted the same question yesterday http://board.flashkit.com/board/showthread.php?t=706670 which i answered to..its better to keep one thread running rather than reposting the same question
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

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