Hi all,
I’m building an XML visualiser, my other thread disappeared but that problem was solved anyway, this one should be much simpler I’m just kicking myself right now that I can’t crack it. I have the following code;
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
xmlLoader.load(new URLRequest("xml/tasks.xml"));
function loadXML(e:Event):void {
xmlData = new XML(e.target.data);
parseTasks(xmlData);
}
function parseTasks(tasks:XML) {
var taskList:XMLList = tasks.item;
for each (var task:XML in taskList) {
var tlength:Number = task.length.text().substring(0,1);
var tpriority:String = task.priority.text();
if (tpriority == "Top") { tpriority = "1"; }
else if (tpriority == "High") { tpriority = "2"; }
else if (tpriority == "Medium") { tpriority = "3"; }
else { tpriority = "4"; }
var tprior:Number = Number(tpriority);
var ttitle:String = task.title.text();
trace(tlength + " & " + tprior + " & " + ttitle);
var newParticle:Particle = new Particle();
newParticle.x = 400 + randRange(-50*tprior, 50*tprior);
newParticle.y = 300 + randRange(-50*tprior, 50*tprior);
newParticle.scaleX = newParticle.scaleY = tlength * 2;
newParticle.buttonMode = true;
newParticle.useHandCursor = true;
newParticle.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
newParticle.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler);
initDragger(newParticle);
function onRollOverHandler(myEvent:MouseEvent) {
feed_txt.text = "Well, " + ttitle;
}
function onRollOutHandler(myEvent:MouseEvent) {
feed_txt.text = " ";
}
if (tprior == 1) { newParticle.alpha = 1; }
else if (tprior == 2) { newParticle.alpha = .8; }
else if (tprior == 3) { newParticle.alpha = .6; }
else { newParticle.alpha = .4; }
this.addChild(newParticle);
}
}
function randRange(min:Number, max:Number) {
return Math.random() * (max - min) + min;
}
function initDragger(mc:MovieClip):void {
mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
function mouseDownHandler(e:MouseEvent):void {
e.currentTarget.startDrag();
}
function mouseUpHandler(e:MouseEvent):void {
e.currentTarget.stopDrag();
}
This bit is the key bit;
newParticle.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
newParticle.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler);
initDragger(newParticle);
function onRollOverHandler(myEvent:MouseEvent) {
feed_txt.text = "Well, " + ttitle;
}
function onRollOutHandler(myEvent:MouseEvent) {
feed_txt.text = " ";
}
I want the rollover state of the movieclips to update the dynamic text box with their associated titles (ttitle), which are pulled from the XML document. The rest of the values are working fine on their individual movie clips and titles are coming out fine in a trace, only the updating of the textbox is causing a problem.
Thanks in advance.