Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Dynamic XML buttons in Flash

11:19 am on Aug 21, 2009 (gmt 0)

New User

5+ Year Member

joined:Aug 21, 2009
posts: 1
votes: 0

I'm trying to assign buttons to random words that are loaded from an XML document into a flash document. The buttons would open an overlay on the same page. The other catch is, I would only like to pick words that fall on the left side of the page (say between x = 55 to 250). So about 4 buttons on the left, overlay to the right. Does that make sense? I've been searching online and I have no idea how to do this.

The current XML load code in actionscript:

var myXML:XML = new XML();
var XML_URL:String = "myXMLFile.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(event:Event):void {

myXML = XML(myLoader.data);
var xmlDoc:XMLDocument = new XMLDocument();
xmlDoc.ignoreWhite = true;
var menuXML:XML = XML(myLoader.data);

for each (var ListItem:XML in myXML..ListItem) {
var listLabel:String = ListItem.itemLabel.toString();
var myFont = new Font1();

var myFormat:TextFormat = new TextFormat();
myFormat.size = 36;
myFormat.align = TextFormatAlign.JUSTIFY;
myFormat.font = myFont.fontName;

var myText1:TextField = new TextField();
myText1.defaultTextFormat = myFormat;
myText1.embedFonts = true;
myText1.antiAliasType = AntiAliasType.ADVANCED;
myText1.text = listLabel;
myText1.textColor = 0xD1D3D4;

myText1.x = 55; //cushion
myText1.y = 50;
myText1.wordWrap = true;
myText1.width = 920;
myText1.height = 660;

var clip_mc = new MovieClip();



And, not sure if this is necessary, but here is the xml doc:

<?xml version="1.0" encoding="utf-8"?>


<itemLabel>I really enjoy his talks on life and lorem ipsum etc. Lots more text.</itemLabel>



Thanks so much for your help!