Monday, March 29, 2010

Class method to return filtered...

I am trying to combine a number of related properties and
methods into one class. One of those methods is to return all
tracks of a cd. A call to the method would look something like
this:



var track:Track = new Track();

var cdTracks:ArrayCollection = new ArrayCollection();

cdTracks = track.getCDTracks(cdID);



The Track Class might look something like:

-------------------------------------------------------------------------------- ---------

private var _theTracks:ArrayCollection;



public function getCDTracks(cdID:Object):ArrayCollection {

getTracks(cdID);

return _theTracks;

}



private function getTracks(cdID:Object):void {

... remote object returns tracks that belong to cdID

ro.addEventListener(ResultEvent.result, tracks_result);

}



private function tracks_result(event:ResultEvent):void {

_theTracks = new ArrayCollection(event.result as Array);

}

-------------------------------------------------------------------------------- --------------



Obviously this won't work but you get the idea. One other
thing i have thought of is to make a call to the db for ALL tracks
of ALL cds upon instantiaion, then filter them when the getCDTracks
method is run. Although i am a little worried this will really slow
down the application when it first runs as this will eventually
lead to TONS of data pre-loading when only a minimal amount is
required.



Thanks!

No comments:

Post a Comment