# \[FMX\] Simple fade in/out of dynamic text (Sorry if too simple)

**URL:** <https://forum.kirupa.com/t/fmx-simple-fade-in-out-of-dynamic-text-sorry-if-too-simple/25628>\
**Category:** flash\
**Created:** [July 15, 2003, 3:42am UTC](https://forum.kirupa.com/t/fmx-simple-fade-in-out-of-dynamic-text-sorry-if-too-simple/25628 "2003-07-15T03:42:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![puckett\_jw](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@puckett\_jw](https://forum.kirupa.com/u/puckett_jw)\
**Post date:** [July 15, 2003, 3:42am UTC](https://forum.kirupa.com/t/fmx-simple-fade-in-out-of-dynamic-text-sorry-if-too-simple/25628/1 "2003-07-15T03:42:16Z")

</div>

Hello all,  
First I would like ot think anyone for taking the time to read my post, and let anyone know that I am not trying to get others to do my work. I will/have read about what I am asking, but I am not exactly sure what direction to take next. With that disclaimer out of the way 🙂

As a newbe to Flash, I am trying to have a simple swf with a static background image that will have phrases at random locatoin slowly fade in, stay for a few seconds, and then fade out. Then the next phrase, and the next one, and then next one, until it loops arround again. The phrases are coming from a database, and I have already created my asp code to give me a page with &phrase=phrase1,phrase2,phrase3,…&status=1&. My fla file has two layers–one for the background and the other for a movie clip wich contains a dynamic text field. My first frame loads my variables, and my second frame looks to see if status equals 1 (the last variable being loaded). If status is not equal 1, I send the head back to frame 1, otherwise I split the phrases into an array, get the height and width of the swf, and init a count var to 0.

```auto
//Look for a way to test the number of times the loop back to frame 1
//has been doen so that we can set a time out. Additionally, maybe put
//logic in the system to test for a blank services?
if (_root.status == 1) {
	Services_Array = Services.split(",");
	
	//Need to get this value here, because the size is returned with any
	//part hanging off the sides, so the text box could be off the end
	Scene_Width = _root._width;
	Scene_Height = _root._height;
	
	count = 0;
} else {
	gotoAndPlay(1);
}

```

From here things get a little cloudy, in frame 3 of my second layer I would like to calculate a random postion for the phrase, so far I have:

```auto
Services_Clip.Services_Text._alpha = 0;

set ("Services_Clip.Services_Text", Services_array[count]);

Text_Width = Services_Text.textWidth;
Text_Height = Services_Text.textHeight;

Text_X = Math.random() * (Scene_Width - Text_Width);
Text_Y = Math.random() * (Scene_Height - Text_Height);

setProperty ("Services_Clip", _x, Text_X);
setProperty ("Services_Clip", _y, Text_Y);

```

However, many parts of that code does not work. I broke the math stuff up so that I could see the values in debug. Anyhow, Text\_Width and Text\_Height are undefined, which causes Text\_X and Text\_Y to be calculated for positions that may put the text off screen? Additionally, I have seen some very nice code on this forum that fades stuff in and out using event function, so should I be headed that way?

I am sorry for such a long post, and really really appricate anyone taking their time to help me out.

Thanks,  
Jimmy Puckett

---

<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:** [July 15, 2003, 7:46am UTC](https://forum.kirupa.com/t/fmx-simple-fade-in-out-of-dynamic-text-sorry-if-too-simple/25628/2 "2003-07-15T07:46:50Z")

</div>

Jimmy, no answer yet, just a welcome & congrats on your post, very clearly explained (not hard to fix too 🙂 ).  
General remarks for now:  
-you mix MX code and old style (setProperty, set), get rid of these before it’s too late…  
-use Services\_mc instead of Services\_Clip to take advantage of code hints  
-this is not defined: Services\_array[count], in Flash use array.\_length  
-better use something less common than (,) to split your stuff, like | , or you won’t be able to use commas in your text…  
-it says you return &phrase=phrase1… from ASP, but then you use Services.split… how do you load, loadVars object or loadVariables? where do you define Services?  
-use lots of trace(variable); all over to check on your values, easier than debug  
be back later to check if this has been answered, gotta leave for work ☹  
Welcome anyway !! 😉

---

<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:** [July 15, 2003, 1:45pm UTC](https://forum.kirupa.com/t/fmx-simple-fade-in-out-of-dynamic-text-sorry-if-too-simple/25628/3 "2003-07-15T13:45:02Z")

</div>

Thank you for the “\_mc” hint. I looked up Naming conventions in the help file to see how to make the other objects code hints work, but it was not helpfull, so I searched the help files for “\_mc” and found the rest of them. That has been a huge help. I have cleaned up the two different styles of code. Anyhow, This is what I now have:

Frame 1, Layer 1:  
\<code\>//loadVariablesNum(“default.asp?flash=services”, 0);  
//Use file for testing, put point to actual asp script  
//when publish  
loadVariablesNum(“services.txt”, 0);\</code\>

Frame 2, Layer 1:  
\<code\>//Look for a way to test the number of times the loop back to frame 1  
//has been doen so that we can set a time out. Additionally, maybe put  
//logic in the system to test for a blank services?  
if (\_root.status == 1) {  
Services\_array = Services.split(",");

```
//Need to get this value here, because the size is returned with any
//part hanging off the sides, so the text box could be off the end
Scene_Width = _root._width;
Scene_Height = _root._height;

count = 0;

```

} else {  
gotoAndPlay(1);  
}\</code\>

Frame 3, Layer 2:  
\<code\>Service\_mc.\_alpha = 25;

Services\_mc.Services\_txt.text = Services\_array[count];

//Move the text feild to a random position on the stage, but make  
//sure that the entire text will fit  
Services\_mc.\_x = Math.random() \* (Scene\_Width - Services\_mc.Services\_txt.textWidth);  
Services\_mc.\_y = Math.random() \* (Scene\_Height - Services\_mc.Services\_txt.textHeight);\</code\>

Frame 4, Layer 1:  
\<code\>//Incroment count or reset it to 0 to restart loop  
count != (Services\_array.length - 1) ? count++ : count = 0;

gotoAndPlay(3);\</code\>

I am sure that there is probably a better way to loop through the items in the array than doing the stuff in frame 4, but I have not figured that out yet.

Could some one please point me in the correct direction to fade up, pause for a few seconds, and then fade down the dynamic text box? I have attached my fla, sample txt, and swf.

Thanks for all of your time.  
-Jimmy Puckett
