Ok, I’m having a problem with my onPress actions when reading them form an XML file. Here’s what I’m trying to do:
Read xml file
duplicate movie clip according to how many xml items there are.
place a different onPress action to each movie clip according to what the corresponding path is in the xml.
my problem is that each time i press any movieclip I always get the last path in the xml file. The loop is over writing the value and when the onPress function is called it uses the last value. How do i get the onPress to remember which movie clip it is and use the appropriate onPress action?
here is my code:
[AS]
import mx.transitions.Tween;
import mx.transitions.easing.*;
//
var Portfolio:XML = new XML();
Portfolio.ignoreWhite = true;
Portfolio.onLoad = function(bSuccess:Boolean):Void {
if(bSuccess){
var xnPortfolio:XMLNode = this.firstChild.firstChild;
var xnItems:XMLNode = xnPortfolio.firstChild;
var xnTotalItems = xnItems.childNodes.length;
var VidUrl:Array = [];
for(var i:Number = 0; i < xnTotalItems; i++) {
c = i + 1;
xnItem = xnItems.childNodes*;
var xnItemThumb:XMLNode = xnItem.attributes.thumb;
var xnVidUrl:XMLNode = xnItem.attributes.movie;
VidUrl[c] = xnVidUrl;
trace(VidUrl[c]);
duplicateMovieClip(thumbnails.thumbnail, "thumbnail"+c, i);
setProperty(thumbnails["thumbnail"+c], _x, 98*i+43);
thumbnails["thumbnail"+c].thumbholder.loadMovie(xnItemThumb);
thumbnails["thumbnail"+c].onRollOver = function () {
this.swapDepths(1000);
new Tween(this, "_xscale", Strong.easeOut, 100, 140, 20, false);
new Tween(this, "_yscale", Strong.easeOut, 100, 140, 20, false);
}
thumbnails["thumbnail"+c].onRollOut = function () {
thumbX = this._xscale;
thumby = this._yscale;
new Tween(this, "_xscale", Strong.easeOut, thumbX, 100, 20, false);
new Tween(this, "_yscale", Strong.easeOut, thumbX, 100, 20, false);
}
thumbnails["thumbnail"+c].onPress = function():Void {
getURL(VidUrl[c]);
}
}
}
}
Portfolio[“target”] = this;
Portfolio.load(“portfolio.xml”);
[/AS]