flash-typewriter effect
- Started
- Last post
- 12 Responses
- krust
i've got a typewriter effect (letters come in one by one) using this script...
//
stop();
function doVidiprinterEffect(textfield,st...
{
if(strtext == undefined)
{
strtext = textfield.htmlText;
textfield.htmlText = "";
}
var string_index = 0;
var max_index = strtext.length;
this.onEnterFrame = function()
{
textfield.text += strtext.charAt(string_index);
string_index++;
if(string_index == max_index)
{
this.onEnterFrame = undefined;
}
}
}
doVidiprinterEffect(this.display...
//question is... can i make it faster? i think it comes in at 24 fps (my movie default). can i double it for instance? or failing that can i bring in 2 characters at a time?
how?
cheers.
- Jerry0
instead of using onEnterframe, which makes your movie depend on framerate, use setInterval. With setInterval you can determine the speed by a parameter. There is a pretty good explanation on how it works in the flash documentation.
Cheers again
- krust0
so i can set a frame rate of 48fps for that movie alone?
will that work online? or only offline (in a presentation)?
i'm sure i've tried that kinda thing a while ago and it didnt work in a browser.
- j_red0
if you use enterFrame, it's based on the frame rate.
if you use setInterval instead, you can change a number and regardless of the frame rate it will run at whatever 'speed' the number is set to.
- Jerry0
stop ();
function doVidiprinterEffect (textfield, strtext, speed) {
if (strtext == undefined) {
strtext = textfield.htmlText;
textfield.htmlText = "";
}
//
var string_index = 0;
var max_index = strtext.length;
//
var printToField = function (){
textfield.text += strtext.charAt (string_index);
string_index++;
if (string_index == max_index) {
clearInterval (sID);
}}
sID = setInterval (printToField, speed)
}
doVidiprinterEffect (this.display_txt, "sdadjas;djkfas'dfjkal;ksjdfasjd... 15);
//
- krust0
thanks alot.
it doesnt seem to make any difference to the speed tho, i've tried changing the '15' value at the end about too.
- Jerry0
It'll work trust me. 15 is very fast, your computer isn't able to display it correctly. The higher the number, the slower the speed.
- krust0
i'm on a g5 with a good monitor. shouldnt i see some difference?
i've tries 1 to 72.. they all seem exactly the same!cheers for your help.
- Jerry0
try values between 1 and 1000,
like 300. 500 etc.
- krust0
sorry - i'm a complete twat.
i was looking at a different clip, anyway, i'm looking at the right clip now. and i've lost the effect with that script, the text just pops up, even with a value of 1.
- Jerry0
try and set the speed to 500
- krust0
still just pops up all at once, no typewriter effect.
- krust0
sorted
stop();
function doVidiprinterEffect(textfield, strtext, speed) {
if (strtext == undefined) {
strtext = textfield.htmlText;
textfield.htmlText = "";
}
string_index = 0;
clearInterval(typeI);
typeI = setInterval(typeF, 1000/speed, textfield, strtext);
}
function typeF(tf, s) {
tf.text += s.charAt(string_index);
string_index++;
if (string_index == s.length) {
clearInterval(typeI);
}
}
doVidiprinterEffect(this.display...