I am trying to make a links box that reads data from a XML file and inturn generates all the buttons and when clicked on will open the specific page in a new browswer window.
this is what I have so far:
a box that reads the XML, makes individual buttons and a scroller to see all the links if there are more than what can be displayed. See example **HERE. **
Here is the code for the actionscript…
//--------------------------------------------------------------------------
// location of the playlist if no html parameter is found
// change "linkbox.xml" if you want another filename ..
//--------------------------------------------------------------------------
_root.linkbox == undefined ? linkbox = "linkbox.xml" : linkbox=_root.linkbox;
//--------------------------------------------------------------------------
// stage variables
Stage.scaleMode = "noScale";
stop();
// linkbox loading
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = loadData;
data_xml.load(linkbox);
// parsing all xml data into flash
function loadData(success) {
if (success) {
website_name = new Array();
address = new Array();
address = this.firstChild.childNodes;
sites_total = address.length;
for (var i = 0; i<sites_total; i++) {
website_name.push(address*.attributes.name);
// buiding linkbox buttons
bot.linkbox.btn.duplicateMovieClip("btn"+i, i);
bot.linkbox["btn"+i]._y = bot.linkbox.btn._y+i*int(bot.linkbox.btn._height) +i;
bot.linkbox["btn"+i].txt = checkDigits(i+1)+". "+website_name*;
bot.linkbox["btn"+i].hit.onPress = function() {
listClick(getURL(address*.attributes.url,"_blank")); };
} }
;}
// list scroller
bot.list_bg.onEnterFrame = function() {
if (hitTest( _root._xmouse, _root._ymouse, true) && this._parent.linkbox._height > this._height ) {
ymin = this._y+this._height - this._parent.linkbox._height;
ymax = this._y+3;
conv = (this._ymouse -15)*1.3/this._height;
conv > 1 ? conv = 1 : null;
conv < 0 ? conv = 0 : null;
this._parent.linkbox.easeY (ymax - conv*(ymax-ymin)); } };
bot.linkbox.setMask(bot.list_bg);
bot._y = 0;
// prefixing a 0 to the list
function checkDigits(toCheck) {
return (toCheck<10) ? toCheck="0"+toCheck : toCheck; }
// easing display and playlist movement
MovieClip.prototype.easeY = function(t) {
this.onEnterFrame = function() {
this._y = int(t-(t-this._y)/1.5);
if (this._y>t-1 && this._y<t+1) {
delete this.onEnterFrame; } }; };
my XML looks like this…
<?xml version="1.0" encoding="UTF-8"?>
<links>
<website url="www.website01.com" name="website 01" />
<website url="www.website02.com" name="website 02" />
<website url="www.website03.com" name="website 03" />
<website url="www.website04.com" name="website 04" />
<website url="www.website05.com" name="website 05" />
<website url="www.website06.com" name="website 06" />
<website url="www.website07.com" name="website 07" />
<website url="www.website08.com" name="website 08" />
<website url="www.website09.com" name="website 09" />
<website url="www.website10.com" name="website 10" />
<website url="www.website11.com" name="website 11" />
</links>
The issue I can’t resolve is the get URL function. Is there some one out there than can help out?..
Thanks
Ken