Flash Script – Cursor-Responsive Text

Share this article

1. Create a text field, name it "txt", and then convert it to a movieclip.

2. Give the movie clip an instance name of "a1".


3. Create a new movieclip and give it an instance name of "a0".

4. Create layers as shown below.


5. In the actions layer in the first key frame, insert the following action:

x = new Array();  
y = new Array();  
text = "Flashcircle.com";  

// mx x value of movieclip  
mx = getProperty("/a1", _x);  
txtlength = length(text);  
/a1:txt = "F";  

//loop through to create duplicate movieclip  
for (i=2; i<=txtlength; i++)  
duplicateMovieClip ("/a1", "a" add i, i);  
setProperty ("/a" add Number(i), _x, mx);  

// substring to put individual letter into movieclip  
set ("/a" add Number(i) add ":txt", substring(text, i, 1));  

6. In the actions layer in the third key frame, insert these actions:

//code to make the text follow  
for(i=1; i<=txtlength; i++)  
x[i] = getProperty("/a" add Number(i-1),_x);  
y[i] = getProperty("/a" add Number(i-1),_y);  
x[i] = x[i]+10;  

7. In the actions layer in the fourth key frame, insert the following:

//code to make the text follow  
for (i=1; i<=txtlength; i++)  
setProperty ("/a" add i, _x, x[i]);  
setProperty ("/a" add i, _y, y[i]);  
gotoAndPlay (2);

8. Right click the "a0" instance movie clip, and insert these actions:

onClipEvent (load)  
startDrag ("", true);  

9. Easy, wasn’t it? Press ctrl+enter to test you movie.

Georgina LaidlawGeorgina Laidlaw
View Author

Georgina has more than fifteen years' experience writing and editing for web, print and voice. With a background in marketing and a passion for words, the time Georgina spent with companies like Sausage Software and sitepoint.com cemented her lasting interest in the media, persuasion, and communications culture.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form