Ok, I had no idea you were supposed to do this. Or maybe I came through the backdoor and read the instructions in the wrong order. At any rate, it seems that DataProvider (mx.controls.listclasses.DataProvider) has a method called addItemAt. If you try to add an item to an index that is greater than the array’s length, it won’t add the value. Now, Flash will do this just fine for you. If you have an array that is empty:
cow = ;
And you decide to add something to position 10, you can:
cow = "moo";
What’s jacked, is DataProvider won’t. So… I guess the trend now is to dimensionalize your array’s length so that method will work properly?
mx.controls.listclasses.DataProvider.Initialize(Array); cow = ; cow.addItemAt(9, "moo"); // Cannot add an item past the end of the DataProvider trace(cow); // undefined cow.length = 10; cow.addItemAt(9, "moo"); trace(cow); // moo
It works when I do some tests here… it just seems so… VB’ish.
One Reply to “Dimensionalize Your Arrays w/ DataProvider”
I’m very new with Flash and all but I do have previous experience on programming and such, and after one whole day of fighting with the same issue I do not have a clue whatsoever on why the dataProvider won’t generate the array length dynamically, which would be nice.
But thanks for the tip, now I can move forward with my list and all !
With best regards,
Comments are closed.