Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Randomly positioned quotes


Robert Poole

3:53 pm on Oct 31, 2008 (gmt 0)

5+ Year Member

I've got a task on my hands to make a flash banner for a website. The banner will have a slideshow going on underneath which is no problem but on top of that I need some actionscript that will do the following...

Basically I have a list of like 100 words, and I want them to be randomly selected from an XML file then to display them at a random position on the banner. Preferably they will fade in real quick, pause for a second, then fade out. I'm guessing there can be two or three going on at any one time so say if the fade in, pause then fade out all lasted 3 seconds I would like to set off a new one every second.

As if this wasn't tricky enough I'd really like to have them each to be a random font, although I guess it would just be selecting from the universal fonts.

One problem I can think of besides the fact my actionscripting is awful is that I'd want to avoid words overlapping if possible.

If anybody can contribute anything that would help me in anyway I'd really appreciate it.

Oh, and... Happy Halloween!


1:43 pm on Nov 1, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Yes, Flash is like web pages in that way, if you apply fonts, you're best to use "web-safe" universal fonts for relatively predictable results.

The best course is to find samples on the web, see how they've done it, and modify to suit. I recall a project similar to what you're asking a few years back, can't post URL's but I've sent a PM to one such coder's site with open source.

Robert Poole

11:53 am on Nov 3, 2008 (gmt 0)

5+ Year Member

Thanks for your help rocknbil, tis a cool effect going on on that page.

I've been plugging away this morning and here's what I have thus far:

import mx.transitions.Tween;
import mx.transitions.easing.*;

var xmlFlash_xml:XML = new XML();
xmlFlash_xml.ignoreWhite = true;
xmlFlash_xml.onLoad = words;

function words(success) {
//onLoad event is triggered when the XML document has been entirely loaded
if (success) {

// success is true if the XML has been loaded with no errors, and false else
var l = 76;
// firstChild property represents the rootnode of the XML document, childNodes property returns an array containing the children nodes of the current node. So, l variable holds the number of children of the root node
var c = Math.floor(Math.random()*l);
var randword = this.firstChild.childNodes[c].childNodes[0].nodeValue;

// Create movieclip to house random word
for(var i=0;i<3;i++) {

//this.createEmptyMovieClip("mcWord", this.getNextHighestDepth(),0,0,200,200);

// Set style for text field
style = new TextFormat();
style.color = 0x0000FF;
style.size =24;
style.align = "center";
style.font = "Verdana";

var w = eval(textField_instances[i][0]);
w.text = randword;
w.autoSize = "left";
var x = Math.floor(Math.random()*650);
var y = Math.floor(Math.random()*150);
w._x = x;
w._y = y;
w.selectable = false;


else {

this basically loads a random word and puts it on a random place on stage. What I really want to do next, but am struggling mightily with, is creating my dynamic text field inside a movie clip, and putting that on the stage so I can later apply the fade effect. Does anyone have any ideas on how to do this? I've tried creating a movieclip called mcWord (commented out in my code) and creating the textfield with mcWord.createTextField... but that just gets me a blank screen.

Any help would be appreciated.


Featured Threads

Hot Threads This Week

Hot Threads This Month