I have a button, a text field and 3 columns of text. I write a number(the number represents the number of lines that the columns have) on the text field and when I press the button I have to rearrange the lines of the columns. Something like this: I write 2 I press and the columns will be redisplayed without the line 2. The code is like this:
var bigArray:Array = new Array();
var itemArray:Array = new Array(“item1”, “item2”, “item3”);
var priceArray:Array = new Array(“p1”, “p2”, “p3”);
var quantityArray:Array = new Array(“q1”, “q2”, “q3”);
bigArray[0] = itemArray;
bigArray[1] = priceArray;
bigArray[2] = quantityArray;
function deleteFromArray(arrObj:Array, arrItem:Number):Array {
var arrOut:Array = arrObj;
for ( var i:Number = 0; i < arrObj.length; i++ ) {
arrOut*.splice(arrItem-1, 1);
}
return arrOut;
};
function showBigArray(nr):Void {
for (var j = 0; j < nr; j++) {
var _itemText:TextField = _root.createTextField("_item"+j, _root.getNextHighestDepth(), 0, 0, 50, 25);
var _priceText:TextField = _root.createTextField("_price"+j, _root.getNextHighestDepth(), 0, 0, 50, 25);
var _quantityText:TextField = _root.createTextField("_quantity"+j, _root.getNextHighestDepth(), 0, 0, 50, 25);
_itemText.text += itemArray[j] + "
";
_itemText._x = 50;
_itemText._y = j*(_itemText._height + 5) + 10;
_priceText.text += priceArray[j] + "
";
_priceText._x = _itemText._x + _itemText._width;
_priceText._y = j*(_priceText._height + 5) + 10;
_quantityText.text += quantityArray[j] + "
";
_quantityText._x = _priceText._x + _priceText._width;
_quantityText._y = j*(_quantityText._height + 5) + 10;
}
}
var string:String;
btn.onRelease = function() {
string = inputTxt.text;
trace(deleteFromArray(bigArray, int(string)));
showBigArray(itemArray.length);
}
showBigArray(itemArray.length);
Thank you.