# Dynamic text

**URL:** https://forum.kirupa.com/t/dynamic-text/63176
**Category:** Uncategorized
**Created:** [September 3, 2004, 2:22pm UTC](https://forum.kirupa.com/t/dynamic-text/63176 "2004-09-03T14:22:24Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![pucca](https://avatars.discourse-cdn.com/v4/letter/p/5f8ce5/32.png) [@pucca](https://forum.kirupa.com/u/pucca)
#### Post date: [September 3, 2004, 2:22pm UTC](https://forum.kirupa.com/t/dynamic-text/63176/1 "2004-09-03T14:22:24Z")

</div>

Hi

I got this scripting from one of your guys, but how do you apply it to a button, created in flash?

```auto
 myArray = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" , "'" , " "];
word = "hello it's me again ha ha ha";
for (i=0; i<word.length; i++) {
myClip = attachMovie("mc", "mc"+i, i);
myClip.ivar = i;
myClip._y = 100;
myClip._x = 0+myClip.ivar*myClip._width;
myClip.targ = word.charAt(myClip.ivar);
myClip.myText.text = myArray[random(myArray.length)];
myClip.counter =random(10)
myClip.onEnterFrame = change;
}
function change() {
this.counter++
if (this.myText.text != this.targ && this.counter<15) {
this.myText.text = myArray[random(myArray.length)];
} else {
this.myText.text = this.targ;
delete this.onEnterFrame;
}
}

 

```

---

<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: [September 3, 2004, 2:53pm UTC](https://forum.kirupa.com/t/dynamic-text/63176/2 "2004-09-03T14:53:34Z")

</div>

> [@pucca](#):
>
> Hi
> 
> I got this scripting from one of your guys, but how do you apply it to a button, created in flash?
> 
> ```auto
> myArray = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" , "'" , " "];
> word = "hello it's me again ha ha ha";
> for (i=0; i<word.length; i++) {
> myClip = attachMovie("mc", "mc"+i, i);
> myClip.ivar = i;
> myClip._y = 100;
> myClip._x = 0+myClip.ivar*myClip._width;
> myClip.targ = word.charAt(myClip.ivar);
> myClip.myText.text = myArray[random(myArray.length)];
> myClip.counter =random(10)
> myClip.onEnterFrame = change;
> }
> function change() {
> this.counter++
> if (this.myText.text != this.targ && this.counter<15) {
> this.myText.text = myArray[random(myArray.length)];
> } else {
> this.myText.text = this.targ;
> delete this.onEnterFrame;
> }
> }
> 
>  
> 
> ```

Looks like something i might have done. have a look here [http://www.kirupaforum.com/forums/showthread.php?t=65050](http://www.kirupaforum.com/forums/showthread.php?t=65050) I made a few examples so you may find what you are looking for. If not, I`ll try and adapt it for you.

---

<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: [September 6, 2004, 8:16am UTC](https://forum.kirupa.com/t/dynamic-text/63176/3 "2004-09-06T08:16:05Z")

</div>

Yehm thats exactly what i’m looking for. that [http://www.yugop.com/](http://www.yugop.com/) thingie.

But I’ve created a button in flash, and want to add the script to my button, but don’t know how? When I open that flash file its only scripting. Sorry I know I sound dumb…  
;(

---

<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: [September 6, 2004, 10:38am UTC](https://forum.kirupa.com/t/dynamic-text/63176/4 "2004-09-06T10:38:26Z")

</div>

Put the loop in a function

```auto
myArray = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "'", " "];
word = "hello it's me again ha ha ha";
function makeRandomtext() {
	for (i=0; i<word.length; i++) {
		myClip = attachMovie("mc", "mc"+i, i);
		myClip.ivar = i;
		myClip._y = 100;
		myClip._x = 0+myClip.ivar*myClip._width;
		myClip.targ = word.charAt(myClip.ivar);
		myClip.myText.text = myArray[random(myArray.length)];
		myClip.counter = random(10);
		myClip.onEnterFrame = change;
	}
}
function change() {
	this.counter++;
	if (this.myText.text != this.targ && this.counter<15) {
		this.myText.text = myArray[random(myArray.length)];
	} else {
		this.myText.text = this.targ;
		delete this.onEnterFrame;
	}
}

```

and call that function with your button

```auto
on(release){
makeRandomtext();
}

```

scotty(-:

---

<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: [September 6, 2004, 11:47am UTC](https://forum.kirupa.com/t/dynamic-text/63176/5 "2004-09-06T11:47:37Z")

</div>

Thanks alot, its working now, but now I wanna know how they manage to change the width and put the “\_\_\_” in at [http://www.yugop.com/](http://www.yugop.com/)

thanks!:cap:

---

<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: [September 6, 2004, 4:44pm UTC](https://forum.kirupa.com/t/dynamic-text/63176/6 "2004-09-06T16:44:15Z")

</div>

> [@pucca](#):
>
> Thanks alot, its working now, but now I wanna know how they manage to change the width and put the “\_\_\_” in at [http://www.yugop.com/](http://www.yugop.com/)
> 
> thanks!:cap:

[http://www.gifsrus.com/testfile/longbuton\_\_\_.swf](http://www.gifsrus.com/testfile/longbuton___.swf)  
Any nearer to what you want?

---

<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: [September 7, 2004, 11:52am UTC](https://forum.kirupa.com/t/dynamic-text/63176/7 "2004-09-07T11:52:33Z")

</div>

YEEEEEEEAAAAHH!!:party: How do you do that?

---

<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: [September 7, 2004, 4:36pm UTC](https://forum.kirupa.com/t/dynamic-text/63176/8 "2004-09-07T16:36:16Z")

</div>

> [@pucca](#):
>
> YEEEEEEEAAAAHH!!:party: How do you do that?

Its basically the same code as one of the attempts in the other post.

---

<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: [September 10, 2004, 8:55am UTC](https://forum.kirupa.com/t/dynamic-text/63176/9 "2004-09-10T08:55:47Z")

</div>

Thanx alot Stringy, got one problem though, the underscores doesn’t show. Why not?

```auto
 function startoff(lets, T) {
 myText.text = "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _";
 displaytext = lets;
 displayLength = lets.length;
 dupdisplaylength = 60
 myinterval = setInterval(messup, 20, T);
 counter =50
}
function messup(T) {
 mystring = "_";
 for (i=0; i<dupdisplayLength; i++) {
  b = displaytext.substr(random(displayLength), 1) != " " ? displaytext.substr(random(displayLength), 1) : "_";
  mystring += b;
 
 }
  if(dupdisplaylength>displaylength){
   dupdisplaylength--
  myString.slice(dupdisplaylength-1,dupdisplaylength)
  T.text = mystring.substr(0,dupdisplaylength);
 }
 
 counter--;
 if (counter==displayLength) {
  counter = 40;
  clearInterval(myInterval);
  myString = displaytext;
  T.text = mystring;
 }
}
myButton.onPress = function() {
 startoff(" welcome ", myText);
};
btn1.onPress = function() {
 startoff(" services ", myText);
};
btn2.onPress = function() {
 startoff(" contact us ", myText);
};

 

```
