Random fading text?

Hi all,

I did a fading text background for a frame page and would also like to have the text appear randomly.

So far I’ve only read about doing random motion of objects in FMX, anyone can help me with doing random static appearances of fading text?

fla attached

TIA! :beer:

heya, this is pretty simple.
put your phrases as static text as different frames in a movieclip called staticPhrases and now for the code to go with it:


where x = the number of frames/phrases in your mc staticPhrases… you can also uses a similar method with an array but for this you needa dynamic text box… which as i understand it is not what you want…

ifu have ne probs, plz feel free to post as i dont have FMX here…


Hi Prophet, thanks for your tip.

I don’t quite get what you meant by “put your phrases as static text as different frames in a movieclip called staticPhrases”. How can I get the text to relocate randomly yet retaining the fading motion tween?

Thanks again! :slight_smile:

oh right you want random locations!!
sorry, i thought you meant you had several different phrases that you wanted it to choose from randomly…
ok so im gonna go ahead and assume you want just the one phrase then… ok… lets say you want your text to appear within the bounds of a box with xy points at (150,150), (300,300)

first things first… you cant set the position of a text field. so put your text field into a movieclip. this movie clip shall have an instance name of textMC. if you have tweens then make sure it all works with this inside a movieclip NOW… work out any bugs if they do occur…

next, create a function to call to change the location of your movie clip…

function moveMC(){

and now for the actual code:

generate random values for its x and y position…

x = Math.random()
y = Math.random()

now this generates a random number between 1 and 0 which we now need to maipulate to get a number between 150 and 300.

difference of 150 and 300 : 300-150=150

x = (x*150)+150
y = (y*150)+150

now we simply apply these values to our movieclip:

textMC._x = x
textMC._y = y

and ending the function…


and then all u have to do is call the function wenever you want it moved! (ie. at a certain frame of a tween, like wen it has faded to complete transparency…)

hope i didnt miss anything out… and also hope u could understand it!! :stuck_out_tongue:



yokey doke, i just got a round to opening ur fla…
ur texts are already in movieclips… you just need to assign them instance names (in the property inspector) to be used within the function… a suggested workaround is this… you name each movieclip sumthing like Rtext1; Rtext2; Rtext3 etc… and then on each frame set variable i equal to the appropriate number before you call the function and rather than the line

textMC._x = x
textMC._y = y


this["Rtext"+i]._x = x
this["Rtext"+i]._y = y

bear in mind ive used the this prefix meaning that the code would have to be placed on the same level as your movieclips… which in your flas would actually just be the root level anyway…

sidenote1: when working with functins you only need to define it once to address it several times
sidenote2: the _x and _y values will work on the registration points of the targeted mc


PS hope i make sense :wink:

Thanks again your Prophet-ness :wink:

I’ll try and feedback once I’m through with it

lol only tryin to help mate :wink: