Prova così:
Codice PHP:
System.useCodepage = true;
function drawRoundedRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number):Void {
with (target_mc) {
beginFill(fillColor, fillAlpha);
lineStyle(1, 0x000000, 100);
moveTo(cornerRadius, 0);
lineTo(boxWidth-cornerRadius, 0);
curveTo(boxWidth, 0, boxWidth, cornerRadius);
lineTo(boxWidth, cornerRadius);
lineTo(boxWidth, boxHeight-cornerRadius);
curveTo(boxWidth, boxHeight, boxWidth-cornerRadius, boxHeight);
lineTo(boxWidth-cornerRadius, boxHeight);
lineTo(cornerRadius, boxHeight);
curveTo(0, boxHeight, 0, boxHeight-cornerRadius);
lineTo(0, boxHeight-cornerRadius);
lineTo(0, cornerRadius);
curveTo(0, 0, cornerRadius, 0);
lineTo(cornerRadius, 0);
endFill();
}
}
dati = new LoadVars();
dati.load("dati.txt");
dati.onLoad = function(ok) {
if (ok) {
for (var n:Number = 0; n<2; n++) {
_root.createTextField("node"+n, n, this["node_x"+n], this["node_y"+n], 200, 20);
_root["node"+n].selectable = false;
_root["node"+n].text = this["node"+n];
_root["node"+n].border = true;
/// RECTANGLES CREATION
_root.createEmptyMovieClip("rectangle"+n, 10+n);
//trace ("rectangle"+n);
_root["rectangle"+n]._y = 100+n;
drawRoundedRectangle(_root["rectangle"+n], 240, 180, 20, 0xCCCCCC, 100);
}
}
}
In pratica il problema stava nel fatto che la function che disegna il rettangolo era dichiarata all'interno dell'oggetto "dati" e c'era un errore di percorso.
In realtà non ho capito bene dove vuoi arrivare con questo codice, ma secondo me invece di creare elementi grafici e campi di testo "al volo" nel codice, ti conviene crearti un movieclip standard dell'elemento che vuoi ciclare e usare un semplice attachMovie nel for.