homepage Welcome to WebmasterWorld Guest from 184.73.40.21
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
Randomly positioned quotes
Robert Poole

5+ Year Member



 
Msg#: 3777533 posted 3:53 pm on Oct 31, 2008 (gmt 0)

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!

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3777533 posted 1:43 pm on Nov 1, 2008 (gmt 0)

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

5+ Year Member



 
Msg#: 3777533 posted 11:53 am on Nov 3, 2008 (gmt 0)

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";

createTextField(textField_instances[i][0],i,0,0,200,100);
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.setTextFormat(style);
w.selectable = false;

}

}
else {
trace("fail");
}
};
xmlFlash_xml.load("words.xml");

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved