A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Typing Effect Speed

  1. #1
    Registered User
    Join Date
    Sep 2018
    Posts
    1

    Typing Effect Speed

    Hello
    I need help I'm trying to control the speed of the text
    this is the code I used:

    Code:
    var effectTxt:String = _root.text1.text;
    _root.text1.text = "";
    var startEff:Number = 1;
    
    _root.onEnterFrame = function (){
    
    	if (effectTxt.length>=startEff) {
    		_root.text1.text = effectTxt.substr(0, startEff);
    		startEff++;
    	}
    	else {
    		
    		clearInterval(writingInterval);
    		delete _root;
    	}
    };
    and this is the code I've been trying to put it

    Code:
    var writingInterval:Number = setInterval(autoWrite, 100);
    From what I have been trying and experiment the code the "autoWrite" is the function name but from the first code I showed when I put a function name I get error saying "Function declaration is not permitted here" but I really need the first code because every time I used with the function name and when I go to another frame by clicking button the text in the next frame gets really fast and so on and so on but if I use the first code and I want to go to another frame by clicking button the text doesn't go fast and displayed in normal speed.

    the code with function name
    Code:
    var i:Number = 0;
    var myMessage:String = "One day... this is where I put the text";
    function autoWrite():Void {
    	if (i<=myMessage.length) {
    		text1.text = myMessage.substr(0, i)+"";
    		i = i+1;
    	} else {
    		clearInterval(writingInterval);
    		delete _root;
    	}
    }
    var writingInterval:Number = setInterval(autoWrite, 100);
    I could do this frame by frame but it is going to take forever I have like a whole story to put in

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    Could you share your fla? As for why the speed changes. I wouldn't be surprised if setting it up in multiple places ends up having them all call the function multiple times extra than it should.

    Any reason you're rewriting the complete text? That will probably cause performance issues. I suggest that you append instead of replace. i.e. _root.text1.text += effectTxt.substr(startEff, startEff+1);
    .

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