-
buttons from XML
hello!
just need a quick answer to this... I've got buttons in my movie which are used for hyperlinks etc... however, I don't want to specify a URL in the actual movie, I want this data pulled from an XML file.
The xml file (for example - link.xml) will read:
<link>"http://www.mylink.com"</link>
and I need the button to pull this link from the <link> field in link.xml. is this possible? if so... would someone be able to tell me what the actionscript would be?!
many thanks!
-
OOP is one letter from OOPS
The script will depend how you set up your movie, as long as all you want to do is pull in the links and not set any text labels on the buttons dynamically, should not be a problem.
-
yeah, no text labels to be set dynamically.... just the link... is there some really easy actionscript fix for this?
-
OOP is one letter from OOPS
how many buttons and what are their instance names, and how many links in the XML?
-
4 buttons...
btn_artlink - reading from <artist>
btn_vvlink - reading from <vvlink>
btn_buylink - reading from <buylink>
and last but not least
btn_staflink - reading from <staflink>
all tags are in links.xml
-
OOP is one letter from OOPS
ok assuming the xml looks like this:
<links>
<artist>http://www.somesite.com/somepage.htm</artist>
<vvlink>http://www.somesite.com/somepage.htm</vvlink>
<buylink>http://www.somesite.com/somepage.htm</buylink>
<staflink>http://www.somesite.com/somepage.htm</staflink>
</links>
ActionScript:
var linksXML:XML = new XML();
//the order of this array is important. the first button listed will get the link listed first in the XML and so on for each button
var linkBtns:Array = new Array(btn_artlink, btn_vvlink, btn_buylink, btn_staflink);
linksXML.ignoreWhite = true;
linksXML.onLoad = function (dat){
if (dat){
for(x=0; x< linkBtns.length; x++){
linkBtns[x].lnk = this.firstChild.childNodes[x].childNodes[0];
linkBtns[x].onRelease = function (){
getURL(this.lnk);
}
}
}else{
trace ("XML failed to load");
}
}
linksXML.load("links.xml");
is the basic idea
-
aww i cant get that to work!
-
OOP is one letter from OOPS
is the fla small enough to post?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|