# \[CS3\] Array Restraints & Displaying in Dynamic Textboxes

**URL:** <https://forum.kirupa.com/t/cs3-array-restraints-displaying-in-dynamic-textboxes/267658>\
**Category:** flash\
**Created:** [August 4, 2008, 3:27pm UTC](https://forum.kirupa.com/t/cs3-array-restraints-displaying-in-dynamic-textboxes/267658 "2008-08-04T15:27:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chulo34](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@chulo34](https://forum.kirupa.com/u/chulo34)\
**Post date:** [August 4, 2008, 3:27pm UTC](https://forum.kirupa.com/t/cs3-array-restraints-displaying-in-dynamic-textboxes/267658/1 "2008-08-04T15:27:42Z")

</div>

Hello, I am fairly new to actionscript, and I’m trying to learn more under the heat of a deadline. I am working on a project for a client where they want the user to be able to build a package of 10 items from the available 41 items.

These are the restraints I am looking to place on my array:  
[LIST]  
[_]Each time an item is clicked, it’s description is added to the array.  
[_]There can only be a maximum of ten items in the array.  
[_]The array cannot have the same item more than once.  
[_]The current items in the array will be listed in ten dynamic textboxes (game1Target.gameInfo\_txt, game2Target.gameInfo\_txt, etc).  
[\*]The user needs to have the ability to remove a specific item from the array if desired, and the other descriptions in the textboxes will shift to fill in the gap (I plan on adding a remove button next to each textbox).  
[/LIST]

I’d greatly appreciate any help you can give. Thanks.

```php
selectedGames = new Array();

var obj = {
	IP:"Game1", 
	WW:"Game2", 
	BC:"Game3", 
	CC:"Game4", 
	MT:"Game5", 
	NK:"Game6", 
	MB:"Game7", 
	PT:"Game8", 
	PS:"Game9", 
	IP2:"Game10",
	WW2:"Game11",
	UJ:"Game12",
	CB:"Game13",
	OK:"Game14",
	OM:"Game15",
	NN:"Game16",
	SK:"Game17",
	CHB:"Game18",
	NO:"Game19",
	DM:"Game20",
	HR:"Game21",
	TR:"Game22",
	BC2:"Game23",
	CC2:"Game24",
	MH:"Game25",
	PH:"Game26",
	AH:"Game27",
	MB2:"Game28",
	SS:"Game29",
	DN:"Game30",
	GW:"Game31",
	OM2:"Game32",
	NK2:"Game33",
	MG:"Game34",
	LC:"Game35",
	MH2:"Game36",
	LL:"Game37",
	PS2:"Game38",
	CHB2:"Game39",
	NN2:"Game40",
	CB2:"Game41"};

var pickGame = function (text, frame) {
return function () {
s = selectedGames.length;
// This is where I try to add each new description to the array
selectedGames[s] = text;
trace(selectedGames);
_root.gotoAndStop(frame+1);
// This is my way of saying if there is one or more items in the array, show each description in a textbox
if (s>=0) {
	_root["game"+(s+1)+"Target"].gameInfo_txt.text = selectedGames[s];
	}
};
};

chooseTeams.onEnterFrame = function() {
	if (_root._currentFrame<11) {
		for (var prop in obj) {
			chooseTeams.playerLineup[prop+"_btn"].onRelease = pickGame(obj[prop], _root._currentFrame);
		}
	}
};

```
