Random text colour change

i’ve a movie clip (e.g. scroll_text) which is consist of 5 words (each word is an individual movie clip). an instance of ‘scroll_text’ movie clip placed in the main timeline with the following script:

onClipEvent (enterFrame) {
_x -= 30;
if (_x<=-2247) {
_y = 40+Math.random()*(400-40);
_x = 1024;
}
}

this script allows the movie clip to do the following:

  1. scroll from right to left
  2. start with a new ‘y’ coordinate for each new scroll
  3. restrict the ‘y’ coordinate between 40 to 400

at the moment i’m trying to achieve the following:

  1. i like to assign a specific colour value randomly to each word embedded in the ‘scroll_text movieclip’. so for each new scroll each word will appear in a different colour. for example,

for the first scroll each word should display in following colour:

word 1: #ffffff
word 2: #000000
word 3: #33ff00
word 4: #cc6699
word 5: #666666

and for the next scroll it will just swap the colour between words. this should happen continuously.

  1. is it possible to achieve?

  2. is there any other alternative to implement this?

any help will be much appreciated.

do you want each individual word to be a different colour, or all words to be the same colour that changes with each scroll?

yes each word should display in different colour for each new scroll. so five words in one scroll should appear in five different colour as mentioned previous mail.

okay, first put this in the first frame of the main timeline:


function RandomColour() {
	Count = 0;
	ColString = "#";
	while(Count < 6) {
		Num = random(16);
		switch(Num) {
			case 10:
				Char = "A";
				break;
			case 11:
				Char = "B";
				break;
			case 12:
				Char = "C";
				break;
			case 13:
				Char = "D";
				break;
			case 14:
				Char = "E";
				break;
			case 15:
				Char = "F";
				break;
			default:
				Char = Num;
		}
		ColString += Char;
		++Count;
	}
	return ColString;
}

now at the start of each scroll, you’ll need this code (make sure the textfield your words appear in is html enabled):


Text = "<font color=\"" + _root.RandomColour() + "\">" + Word1 + "</font>" + "<font color=\"" + _root.RandomColour() + "\">" + Word2 + "</font>" + "<font color=\"" + _root.RandomColour() + "\">" + Word3 + "</font>" + "<font color=\"" + _root.RandomColour() + "\">" + Word4 + "</font>" + "<font color=\"" + _root.RandomColour() + "\">" + Word5 + "</font>";

should do the job, let me know how you get on

would you please check my source file, its not working

okay, but you’ll have to post your source file/code

i’ve tried to attach last time but didn’t work. can i send it to you directly instead?

sure, send it to m_andrews808@hotmail.com

I’m a bit confused by the fla you sent me, do you want each word to randomly pick a colour from a predefined selection of colours, or do you want each word to be a colour generated randomly?

it should only use the colour that specifed in the action script

check your mail