Flash tutorials
Home 3D (2) Actionscripting (66) Animation (100) Audio (4) Drawing (7) Full flash sites (4) Getting Started (15) Navigation (25) Special Effects (54) Text Effects (38)

Moving letters with mouse

11.5.2009, 22:57    Total views: 12239
This, step by step lesson, will show you how to create that every letters follow the mouse using the action script code.











Example:




Step 1

Create a new flash document and set your Flash movie's frame rate to 28 and click ok.



Step 2


Go now to the Action Script Panel, and enter this code inside the actions panel:

Text = "FlashVault.net";
letters = Text.split("");

// This action script code shows text for this animation

letterformat = new TextFormat();
letterformat.font = "Trebuchet MS";
letterformat.align = "center";
letterformat.size = "14";
letterformat.color = 0xffffff;
letterformat.bold = true;

// This code shows a new TextFormat object, size, type, color of font and the last line just creates bold font.

spacing = 6;
speed = 4;

// This code shows size of the area between the letters and speed.

for (var LTR = 0; LTR        mc = _root.createEmptyMovieClip(LTR+"l", LTR);
        mc.createTextField(letters[LTR]+"t", LTR, LTR*spacing, 10, 20, 20);
        with (mc[letters[LTR]+"t"]) {
                text = letters[LTR];
                setTextFormat(letterformat);
                selectable = false;
        }
        if (LTR) {
                mc.prevClip = _root[(LTR-1)+"l"];
                mc.onEnterFrame = function() {
                        this._x += (this.prevClip._x-this._x+5)/speed;
                        this._y += (this.prevClip._y-this._y)/speed;
                };
        } else {
                mc.onEnterFrame = function() {
                        this._x += (_root._xmouse-this._x+10)/speed;
                        this._y += (_root._ymouse-this._y)/speed;
                };
        }
}

// This action script code creates a new movieclip on the timeline and textfield inside the new movieclip.

Have a nice day!

Download source file (.fla)
Have questions about this tutorial?
Visit our friendly Community Forums!
Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!

Top tutorials

1. Advanced full flash site - Part 1
Total views: 225065

2. Water effect
Total views: 169137

3. Photo slide show
Total views: 156961

4. High-tech city animation
Total views: 154359

5. Special Picture Effect
Total views: 148419

Related links