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

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 :slight_smile:

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.

//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:

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

Jimmy, no answer yet, just a welcome & congrats on your post, very clearly explained (not hard to fix too :slight_smile: ).
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 :frowning:
Welcome anyway !! :wink:

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