Here's some code which is a quick and dirty approximation of the effect. I just did this and it could do with some optimisation but the principle is the same and it should give you some clues.
You'll need to create two clips on the stage - the first one is an empty dynamic textbox to contain a single letter of your text (give it the variable name "letter") and convert it to a movieclip with the instance name "emptyBox".
Then create another, dummy, clip so you can attach this code...
onClipEvent (load) {
// set up text string
text = " Whatever text you want to display on the screen, the more the better but it's boring to type...";
spacing = 6;
count = 1;
speed = 3;
// create a clip for each letter, fill it and set its eventual end point on the screen
for (i=1; i<text.length; i++) {
duplicateMovieClip (_root.emptyBox, "type"+i, i);
_root["type"+i].letter = text.charAt(i);
_root["type"+i].xTarget = spacing*i;
_root["type"+i].yTarget = 100;
_root["type"+i]._visible = false;
}
}
onClipEvent (mouseMove) {
// display the letters as the mouse is moved
if (count<text.length) {
_root["type"+count]._visible = true;
_root["type"+count]._x = _root._xmouse;
_root["type"+count]._y = _root._ymouse;
count++;
}
}
onClipEvent (enterFrame) {
// move each clip towards it's home position on the screen
for (i=1; i<=count; i++) {
xMove = (_root["type"+i].xTarget-_root["type"+i]._x)/speed;
yMove = (_root["type"+i].yTarget-_root["type"+i]._y)/speed;
_root["type"+i]._x += xMove;
_root["type"+i]._y += yMove;
}
}
Everytime you move the mouse, text from your string should appear and move across the screen to form a sentence. The code slows down a bit as more clips enter the screen so you'll have to play with it to make it slicker if you want to add the kind of extra movement on kazsh.com.
Set the movie framerate as high as you can to keep things as smooth as possible.
|