Flash Actionscript Q
- Started
- Last post
- 8 Responses
- abizzyman
okay... unfit - if you're there.. I'm ready!
I understand how to write and create a really simple typewriter effect using : text.substring.
What I want is to also code a blinking underscore ( _ ) at the end of each line of text. I only want it to blink 3 times (if that) and then move on to the next frame.
I understand how to check the length of the string to see if it's completed then move to the next frame... it's just creating the blinking cursor where I'm having a problem.
Here's what I have on frame one:
stop();
function typewriter(chars) {
this.onEnterFrame = writeText;
this.count = 1;
this.message = chars;
this.maxLength = this.message.length;
}
function writeText(){
this.typewriter_txt.text = this.message.substr(0, this.count);
this.count++;
if (this.count>this.maxLength) {
gotoAndStop(2);
}
}
typewriter("hello everybody! \nHow are you?");then I duplicate that for frame two and just change the message.. but I want the underscore to blink a couple of times before the 'message' is complete.
Anybody have any ideas?
- abizzyman0
*ba-ump!
- abizzyman0
I can't figure it out!!!!!
BUMP!!!
- unfittoprint0
your count is always being set to 1, therefore never reaching three.
initiate count ouside the onEnterFrame event.
- abizzyman0
I'm not sure I follow...
... I want the full string to type in... then an underscore to blink three times at the end of the string...
... then once it's blinked three times, I want timeline to move to the next frame and repeart w/a different string.
- Mick0
See if this works...
stop();
function typewriter(chars) {
this.onEnterFrame = writeText;
this.count = 1;
this.i = 1;
this.message = chars;
this.maxLength = this.message.length;
}function writeText(){
this.typewriter_txt.text = this.message.substr(0,this.count...
count++;
if(count>this.maxLength){
var isEven = count/2;
if(isEven == Math.floor(isEven)){
typewriter_txt.text +="_";
}
}
if(count>this.maxLength+6) {
gotoAndStop(2);
}
}
typewriter("hello everybody! \nHow are you?");
- Mick0
You can delete this from the last post (put it in for testing - forgot to delete)...
this.i = 1;
- unfittoprint0
I'don't use code spread in multiple frame. You shoul stick the one only.
Instead of onEnterFrame you should use setInterval [you'll be able to decrease/increase the 'typing' speed according to your needs).
For the blinking 'thing' you should do the following:
After the maxlength codition is found, clear your Interval (or your onEnterFrame if u still want to use it) and initiate a new one where you use add_=true/add_=false to add/subtract the "_" to your whole string.
to make it three times u should also add a count2 and increment it each 2 loops.
- abizzyman0
thanks, I appreciate Mick and Unfit.
... got it going like I want.