Hi everyone
I have this xml file that looks like this:
<comments>
<key caption="User4">
<entry name="main" added="11-01-2009" src="Rain" />
<entry name="loader" added="11-01-2009" src="LG" />
</key>
<key caption="Dummy - Do not remove"></key>
</comments>
and id like to add a text link like this to each “entry name”:
<link href="Title1.html" text="Title1" />
Note: Each “entry name” currently becomes a link in itself when displayed. I need the new link to be a separate link.
And this is the xml code in the actionscript:
function dateToNum(time)
{
var day = Number(time.substr(0, 2));
var month = Number(time.substr(3, 2));
var year = Number(time.substr(6, 4));
return (Date.UTC(year, month - 1, day));
} // End of the function
function Key(num, caption, entries)
{
this.num = num;
this.caption = caption;
this.entries = entries;
} // End of the function
function Entry(num, name, added, src)
{
this.num = num;
this.name = name;
this.added = added;
this.src = src;
} // End of the function
function handleKeyRollover()
{
var c = this._parent;
if (!c.key.open)
{
c.mcLeftArrow._visible = true;
} // end if
} // End of the function
function handleKeyRollout()
{
var c = this._parent;
c.mcLeftArrow._visible = false;
} // End of the function
function handleKeyPress()
{
var c = this._parent;
c.key.open = !c.key.open;
c.mcDownArrow._visible = c.key.open;
c.mcLeftArrow._visible = !c.key.open;
c.key.mc.entries._visible = c.key.open;
_root.calcNewPos();
} // End of the function
function handleSBPress()
{
this.startDrag(false, this._x, 0, this._x, (1 - this._yscale / 100) * mHeight);
} // End of the function
function handleSBRelease()
{
this.stopDrag();
} // End of the function
function handleEntryPress()
{
if (!this.entry.selected)
{
for (i = 0; i < _root.keys.length; i++)
{
var c = _root.keys*;
for (j = 0; j < c.entries.length; j++)
{
c.entries[j].selected = false;
c.entries[j].mc.mcHighlight._visible = false;
} // end of for
} // end of for
this.entry.selected = true;
this._parent.mcHighlight._visible = true;
var s = "javascript:setSRC(\'" + this.entry.src + ".html\');void(0)";
_root.sitetemplatecategory = this.entry.src;
_root.sitetemplate = this.entry.name;
loadMovie(_level0.interfacedir add "/" add _root.sitetemplatecategory add "/" add _root.sitetemplate add ".swf", "_root.loadsitepreview");
loadMovie(_level0.templatedir add "/" add _level0.category add "/" add _level0.theme add ".swf", "_root.loadsitethemepreview");
var lc = new LocalConnection();
lc.send("lcTitle", "changeTitle", "Témoignages|" + this.entry.name);
delete lc;
} // end if
} // End of the function
function handleEntryRollOver()
{
this._parent.mcHighlight._visible = true;
} // End of the function
function handleEntryRollOut()
{
if (!this.entry.selected)
{
this._parent.mcHighlight._visible = false;
} // end if
} // End of the function
function refreshDisplay()
{
var i = 0;
while (i < keys.length)
{
c = keys*;
c.mc._y = (c.pos - c.mc._y) / 8 + c.mc._y;
++i;
} // end while
var c = keys[keys.length - 1];
var ys = 100 * mHeight / c.mc._y;
_root.scrollbar._yscale = Math.max(minYScale, ys);
_root.scrollbar._visible = _root.scrollbar._yscale < 100;
_root.scrollbar._y = Math.max(0, Math.min(_root.scrollbar._y, (1 - _root.scrollbar._yscale / 100) * mHeight));
var percentScroll = _root.scrollbar._y / ((1 - _root.scrollbar._yscale / 100) * mHeight);
var scrollLength = (100 / ys - 1) * mHeight;
_root.main.content._y = -1.003000E+000 * percentScroll * scrollLength;
} // End of the function
function calcNewPos()
{
var d = 0;
var i = 0;
while (i < keys.length)
{
c = keys*;
c.pos = d;
d = d + (c.open * c.height + keySpacing);
++i;
} // end while
} // End of the function
function createAssets()
{
var today = new Date();
todayStamp = Date.UTC(today.getFullYear(), today.getMonth(), today.getDay());
_root.createEmptyMovieClip("main", 0);
_root.main.createEmptyMovieClip("content", 0);
_root.main.onEnterFrame = refreshDisplay;
_root.createEmptyMovieClip("mask", 1);
_root.createEmptyMovieClip("scrollbar", 2);
_root.scrollbar.onPress = handleSBPress;
_root.scrollbar.onRelease = handleSBRelease;
_root.scrollbar.onReleaseOutside = handleSBRelease;
with (_root.scrollbar)
{
beginFill(10799871);
lineTo(16, 0);
lineTo(16, mHeight);
lineTo(0, mHeight);
endFill();
} // End of with
_root.scrollbar._x = 226;
_root.scrollbar._visible = false;
_root.countTotal = 0;
_root.countNew = 0;
var i = 0;
while (i < keys.length)
{
var c = keys*;
c.drawSelf();
var j = 0;
while (j < c.entries.length)
{
c.entries[j].drawSelf(c.mc.entries);
++j;
} // end while
c.countNew();
++i;
} // end while
_root.main.content["key" + (keys.length - 1)]._visible = false;
var lc = new LocalConnection();
lc.send("lcTitle", "changeTitle", "Témoignages|Liste alphabétique");
lc.send("lcTitle", "changeTotal", _root.countTotal + "|" + _root.countNew);
delete lc;
} // End of the function
function readXML()
{
var main = file.firstChild.childNodes;
keys = new Array();
var i = 0;
while (i < main.length)
{
keys.push(new Key(i, main*.attributes.caption, new Array()));
var cKey = keys*;
var j = 0;
while (j < main*.childNodes.length)
{
var ca = main*.childNodes[j].attributes;
cKey.entries.push(new Entry(j, ca.name, ca.added, ca.src));
++j;
} // end while
++i;
} // end while
createAssets();
} // End of the function
function xmlLoaded(success)
{
if (success)
{
readXML();
} // end if
clearInterval(xmlInt);
} // End of the function
function updateLoader()
{
if (file.getBytesTotal() > 100)
{
_root.pc.text = Math.round(file.getBytesLoaded() / file.getBytesTotal() * 100) + "%";
var p = file.getBytesLoaded() / file.getBytesTotal();
_root.pl.mask.clear();
dt = 1.047198E-001;
for (i = 0; i < 60; i++)
{
if (i + 1 < p * 60)
{
var ang = i / 30 * 3.141593E+000;
with (_root.pl.mask)
{
moveTo(0, 0);
beginFill(0);
lineTo(50 * Math.cos(ang), 50 * Math.sin(ang));
lineTo(50 * Math.cos(ang + dt), 50 * Math.sin(ang + dt));
endFill();
} // End of with
continue;
} // end if
break;
} // end of for
} // end if
} // End of the function
keySpacing = 22;
entrySpacing = 16;
afterEntrySpacing = 5;
mWidth = 245;
mHeight = 450;
minYScale = 5;
stayNew = 1209600000;
Key.prototype.drawSelf = function ()
{
_root.main.content.attachMovie("mcKey", "key" add this.num, this.num);
this.mc = _root.main.content["key" add this.num];
this.mc.mcLeftArrow._visible = false;
this.mc.mcDownArrow._visible = false;
this.mc._y = keySpacing * this.num;
this.mc.txtCaption.text = this.caption;
this.mc.btnKey._useHandCursor = false;
this.mc.btnKey.onRollOver = handleKeyRollover;
this.mc.btnKey.onRollOut = handleKeyRollOut;
this.mc.btnKey.onPress = handleKeyPress;
this.mc.btnKey.onReleaseOutside = handleKeyRollOut;
this.mc.key = this;
this.mc.createEmptyMovieClip("entries", 0);
this.mc.entries._y = keySpacing;
this.mc.entries._visible = false;
this.open = false;
this.height = this.entries.length * entrySpacing + afterEntrySpacing;
this.pos = this.mc._y;
this.catt = this.caption;
};
Key.prototype.countNew = function ()
{
var count = 0;
var i = 0;
while (i < this.entries.length)
{
if (this.entries*.isNew)
{
++count;
} // end if
++i;
} // end while
var str = "<p align=\'right\'><font color=\'#666666\'>(" + this.entries.length + ")</font> ";
var str = str + "</p>";
this.mc.txtCount.htmlText = str;
_root.countTotal = _root.countTotal + this.entries.length;
_root.countNew = _root.countNew + count;
};
Entry.prototype.drawSelf = function (location)
{
location.attachMovie("mcEntry", "entry" add this.num, this.num);
this.mc = location["entry" add this.num];
this.mc._y = this.num * entrySpacing;
this.mc.txtName.text = this.name;
this.markNew();
this.mc.mcNew._visible = this.isNew;
this.mc.btnEntry.onPress = handleEntryPress;
this.mc.btnEntry.onRollOver = handleEntryRollover;
this.mc.btnEntry.onRollOut = handleEntryRollOut;
this.mc.btnEntry.entry = this;
this.mc.mcHighlight._visible = false;
this.selected = false;
};
Entry.prototype.markNew = function ()
{
var addedStamp = dateToNum(this.added);
this.isNew = false;
if (todayStamp - addedStamp < stayNew)
{
this.isNew = true;
} // end if
};
file = new XML();
file.ignoreWhite = true;
file.onLoad = xmlLoaded;
file.load("list_sitetemplates" add _level0.userlevel add ".xml");
_root.pl.createEmptyMovieClip("mask", 0);
_root.pl.mask._rotation = -90;
_root.pl.ring.setMask(_root.pl.mask);
xmlInt = setInterval(updateLoader, 50);
I’ll paypal $20 to anyone that could successfully help me with this.
Thank you