Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : basic scripting question


southcorp
2/5/2004 11:38:15 PM
I have a couple of TextInput fields, and when you fill them out and hit a "submit" button, it saves that data as an item in a dataSet component. like this:

btnSubmit.onRelease = function() {
dataSet.addItem({name: nameInput.text, ssn: ssnInput.text});
};

But I also want to the button to automatically save a sort of reference number for each one (one that the user doesn't have to input): like "Entry 1" for the first one, "Entry 2" for the second, etc... How do I code the button to check how many items are in the dataSet, and then append whatever number would come next, onto the end of a string that says "Entry _"?


thanks,

richard

eonyron
2/6/2004 8:42:53 AM
Use server side Languages

CesareRocchi
2/6/2004 2:17:14 PM
Just use an array.

The push automatically puts an item at the end (last position available). The you don't have to calculate
where to put a new item. And you can use the position in the array to index all your stuff.

HTH

-c.

Troyan
2/8/2004 4:05:46 AM
DataSet object hasn't a length property? Have you tried DataSet.length?
If it's wrong, try...

var numItems=0; for (i in DataSet) { numItems++; }
trace(numItems);

It's such a stupid code that runs a loop just to get the length, but it works ;P

AddThis Social Bookmark Button