# \[fmx\]text effect

**URL:** https://forum.kirupa.com/t/fmx-text-effect/18586
**Category:** flash
**Created:** [April 18, 2003, 10:05am UTC](https://forum.kirupa.com/t/fmx-text-effect/18586 "2003-04-18T10:05:29Z")
**Posts on this page:** 5
**Page:** 2

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 18, 2003, 1:43pm UTC](https://forum.kirupa.com/t/fmx-text-effect/18586/21 "2003-04-18T13:43:20Z")

</div>

I created an extra variable:

```auto

var startX = 100;

```

and changed a line in the onEnterFrame:

```auto

_root["char"+i]._x += ((((i - myArray.length/2)*spacing) - _root["char"+i]._x)/speed) + startX;

```

Hope you like it 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 18, 2003, 1:53pm UTC](https://forum.kirupa.com/t/fmx-text-effect/18586/22 "2003-04-18T13:53:42Z")

</div>

thank you, that is it!

if i can do for you something, let me know!!!

but, i wil ask 1 thing more, euh, 2 thing

1. can you explain me the script, i will learn it
2. where can i put an apha en can i create more line whith the same effect?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 18, 2003, 4:05pm UTC](https://forum.kirupa.com/t/fmx-text-effect/18586/23 "2003-04-18T16:05:07Z")

</div>

new code (including random alpha change):

```php

var speed = 2;          
var pause = 2000;
var spacing = 10;
var startX = 100;
var myAlpha = 100;
var myText = "Virusdoder";

myArray = myText.split("");

for(i=0; i<myArray.length; i++){
	character = _root.attachMovie("myMC", "char"+i, i);
	character._x = i*10;
	character.myChar.text = myArray*;
}
function changeSpacing(){
	spacing = Math.random()*40 + 10;
	myAlpha = Math.random()*95 + 5;
}
_root.onEnterFrame = function(){
	for(i=0; i<myArray.length; i++){
		_root["char"+i]._x += ((((i - myArray.length/2)*spacing) - _root["char"+i]._x)/speed) + startX;
		_root["char"+i]._alpha += (myAlpha - _root["char"+i]._alpha)/speed;
	}
}
setInterval(changeSpacing,pause);

```

In order to work properly you also have to embed the font outline. Go into myMC and in the Properties panel of the textfield, click on Character. Make sure that the option ‘All Characters’ is ticked.

As for the explanation:

```php

var myText = "Virusdoder";

```

This is the text that is to be animated

```php

myArray = myText.split("");

```

This line breaks the variable myText into separate characters and puts them into an array.  
In this case the resulting array is _{v,i,r,u,s,d,o,d,e,r}_

```php

for(i=0; i<myArray.length; i++){
	character = _root.attachMovie("myMC", "char"+i, i);
	character._x = i*10;
	character.myChar.text = myArray*;
}

```

With this loop you place an instance of myMC on stage and give it a unique instancename and in it’s own level.  
E.g. you get _char0_ on level 0, _char1_ at level 1 etc.

Note: to be able to use attachMovie() you need to export the mc for actionscript: rightclick on the mc in the library and choose Linkage. Then tick the option ‘Export for Actionscript’.

By assigning the attachMovie() to the variable ‘character’ I can set properties such as the \_x and the content of the textfield within the loop by using e.g ‘character.\_x’.

Then the actual function:

```php

function changeSpacing(){
	spacing = Math.random()*40 + 10;
	myAlpha = Math.random()*95 + 5;
}

```

This sets a variable called 'spacing to a random value. Math.random() generates a value between 0 and 1. By multiplying by 40 and then adding 10, you get a value between 10 and 50.  
In the same way, myAlpha gets a value between 5 and 100.

```php

_root.onEnterFrame = function(){
	for(i=0; i<myArray.length; i++){
		_root["char"+i]._x += ((((i - myArray.length/2)*spacing) - _root["char"+i]._x)/speed) + startX;
		_root["char"+i]._alpha += (myAlpha - _root["char"+i]._alpha)/speed;
	}
}

```

onEnterFrame means that this is executed at the framerate of the movie, in this case 24 times per second.  
Again, there is a loop, in which every mc that was created with the attachMovie() command gets a new \_x and \_alpha.  
This is actually based on the easing motion tutorial found [here](http://www.kirupa.com/developer/mx/followease.htm)

the last part:

```php

setInterval(changeSpacing,pause);

```

just says to execute the changeSpacing function with a time-interval of the amount of milliseconds specified by the variable ‘pause’.

I think that’s about it.

Just let me know if my explanation isn’t clear at any point. 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 19, 2003, 4:41pm UTC](https://forum.kirupa.com/t/fmx-text-effect/18586/24 "2003-04-19T16:41:30Z")

</div>

thank you very much.

i understand everything  
when you have a problem, let me now

😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 20, 2003, 3:22pm UTC](https://forum.kirupa.com/t/fmx-text-effect/18586/25 "2003-04-20T15:22:00Z")

</div>

Cheers.

…and the only problem I’m having is that I don’t have a Flash-related job. If you could help me with that… (-:

[Previous page](https://forum.kirupa.com/t/fmx-text-effect/18586.md?page=1)
