Home Tutorials Forums Articles Blogs Movies Library Employment Press
Prev Previous Post   Next Post Next
Old 04-26-2005, 10:09 AM   #1
Registered User
Join Date: Apr 2005
Posts: 2
Default Creating a link button from XML content


I am working on a CD ROM interface that draws it's content from an XML document. I have a menu which is created "onLoad" using the XML content, and text boxes on the stage which draw their content from the XML doc according to which button in the menu is clicked. All this works fine.

I would also like to add a link button that is generated from an attribute of a node of the XML document - this is the part I can't get to work.

I have tried to do this using the same code as in the menu. I originally got the menu code off the web, but have changed it alot (learning as I go) and added stuff. I understand everything in the code except the use of _root["item"+a] (I know what "item"+a is, but am confused about the use of _root[]) in the menu script, and consequently I think I may be using _root incorrectly in the link button part that I have added.

The script is below, and it all works except the actual link (the URL displays in the new movie clip as it should, but there is no mouse over action and you can't click on it).

Any help or guidance would really be appreciated - Thanks

ActionScript Code:
stop(); menu = new XML(); menu.ignoreWhite = true; menu.load("menu.xml"); menu.onLoad = function(){         //create an array "items" that contains all the info in the "item" nodes     items = this.firstChild.firstChild.childNodes;     for(a = 0; a<= items.length-1; a++){         //attach a new instance of menuItem         _root.attachMovie( "menuItem", "item"+a, a);         //insert text from the "header" attribute into the button's text field         _root["item"+a].itemText.text = items[a].attributes.header;         //Move the movie clip ACCROSS per execution of the loop and set x value         _root["item"+a]._x = 5;         _root["item"+a]._y = 40 + 20*a;                     //create new variables (?) to hold the attributes from the relevant "item" node         _root["item"+a].showHeader = items[a].attributes.header;         _root["item"+a].showLicence = items[a].attributes.licence;         _root["item"+a].showDescription = items[a].attributes.description;         _root["item"+a].showURL = items[a].attributes.link;                //create a link button using information from the "link" attribute        _root["item"+a].onRelease = function(){             _root.attachMovie("itemURL", "buttonLink", a, {_x:350, _y:109});             _root["buttonLink"].URLtxt.text = this.showURL;             _root["buttonlink"].onRelease = function(){                 getURL(this.showURL, "_blank");             }         //populate text boxes with information form the relevant node attributes            itemHeader.text = this.showHeader;         itemLicence.text = this.showLicence;         itemDesc.text = this.showDescription;         }     } }
mightymouse is offline  

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 06:57 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.