Groups | Blog | Home
all groups > flash actionscript > april 2006 >

flash actionscript : can you *copy* a recordset?


sneakyimp
4/19/2006 7:23:36 PM
I'm using flash remoting to retrieve a pretty large data recordset from my
server. Then, I'm displaying that recordset on two different datagrids which
have to be able to sort the data independently. If they use the same
recordset, then sorting one will sort the other.

I currently have them set up to each load the same recordset independently,
but this is currently a list of 1800 products! it's really taxing
bandwidth-wise.

Is there any way to 'copy' the results of a recordset?
sneakyimp
4/20/2006 12:26:15 AM
ok since i'm not getting any help, i figure I'll post some of my efforts to
hopefully encourage some smart person to help me here....

I googled and googled and found this:

http://livedocs.macromedia.com/flashremoting/mx/Using_Flash_Remoting_MX/UseASDat
a6.htm#1181461

Tantalizing hints there. the RecordSet.filter() function is supposed to
return a *copy* of a Recordset.

BUT, there are problems with that as described here:

http://www.flashant.org/index.php?p=21&more=1&c=1

Apparently the filter() function retains references to the original object.
SHAME on Macromedia!

At any rate, it appears as though I can add a RecordSet.copy() method to the
RecordSet object itself by editing the RecordSet.as files in the Macromedia
install directory. I don't know is this will work, and I'm wary of doing
something that would not work on everybody's flash player, but I was thinking I
could add this to the RecordSet.as file right after the filter() prototype.

Does anyone know if that will work??

RecordSet.prototype.copy = function()
{
if (!this.checkLocal()) return;

// create a new, empty RecordSet
var result = new RecordSet(this.mTitles);

// loop over all the records in the current RecordSet
// find the ones that the the filter function approves of,
// and add it to the result
var rcount = this.length;
for(var i = 0; i < rcount; i++)
{
var item = this.getItemAt(i);
//
// RecordSet.as copy() method by sneakyimp
// Copyright (c) 2006
// special thanks to Aral Balkan. http://www.BitsAndPixels.co.uk
//
var copyOfItem = new Object();

for ( var j in item )
{
copyOfItem [ j ] = item [ j ];
}

if ( ( copyOfItem != null ) && ( copyOfItem != 1 ))
{
result.addItem( copyOfItem );
}
}

//trace("RecordSet.filter: " + NetServices.objectToString(result));
return result;
};
sneakyimp
4/20/2006 5:36:56 PM
in addition to the main RecordSet.as file (about 18k) in Flash\en\First
Run\Include, there is a RecordSet.as in Flash\en\First Run\Include\Classes.

I assume I'd need to declare the new method there, no?

Also, if i change *my* RecordSet.as files, will my flash movies still work for
everyone else of would I be declaring something the flash player cannot handle?
AddThis Social Bookmark Button