I cant share the full actual code because it is dependent on too many things. I have tried to pull a snippet out and edit it to make it understandable.
The idea here is that I have a block of data called "m_in_videoStorage_generic.items" which needs to be processed. The processing is too slow and I cant make it faster. I want it to happen in the background. So I created an interval to do a little bit of processing each time the interval is hit, and to broadcast an event when all of the data is processed. This concept can probably be turned into a generic class by passing in the function that gets periodically processed. That function would just have to obey certain rules about keeping track of how much it gets done each "slice". In the below code m_genericSyncOffset is how far we have gotten through the array, and k_sliceSize is how many items to process in each cycle through the array. So the key to my concept is being able to break up long operation into a collection of more mamageable chunks. Sometimes this is not possible, but often it is. Regards Hank CODE: ----------------------------------------------------------------------------------------------------------- private static k_sliceSize:Number = 10; private static m_genericSyncOffset:Number; private function syncGenericStorage():Void{ m_genericSyncOffset = 0; m_genericStorageIntID = setInterval(this,"syncGenericStorageSlice",1); } private function syncGenericStorageSlice():Void{ var generic:Array = m_in_videoStorage_generic.items; var loopMax:Number = generic.length; var i:Number; if (loopMax>m_genericSyncOffset+k_sliceSize) loopMax = m_genericSyncOffset+k_sliceSize; for (i=m_genericSyncOffset;i<loopMax;i++){ var item:Object = generic[i]; // *** PROCESS DATA IN "generic" HERE *** } if (i>=generic.length){ //messageWire is just a class I created that is a type of event system //if I want to notify some other piece of my system about a given //even, I "publish" that even and anyone who is subscribed to that even //is notified. This could be done with a standard event. // pseudo code: m_messageWire.publish( tell system data is processed); clearInterval(m_genericStorageIntID); } else m_genericSyncOffset = i; } ------------------------------------------------------------------------------------------------------- On 12/13/05, Meinte van't Kruis <[EMAIL PROTECTED]> wrote: > sounds interesting, would like to have a peek at the code. > Do you have it online somewhere to share? > > thx, > Meinte > > On 12/12/05, hank williams <[EMAIL PROTECTED]> wrote: > > > > There is some truth to this, but parf of good architecture is about > > tailoring what you have to what you need. In my current application, I > > have a collection of data that needs to be processed. Under certain > > circumstances I actually get the dialog box about the app running > > slowly. > > > > So what I did was to make this data processing "chunkable", and then I > > use setInterval to calculate pieces of it at a time. I was thinking > > about the concept of a separate swf but this turned out to be easier. > > > > So I guess my point is just that threading would be nice. I use it > > sparingly in my java side work. But I do find that it is generally > > possible to do what you want to do in a single threaded flash player. > > > > Regards > > Hank > > > > On 12/12/05, Meinte van't Kruis <[EMAIL PROTECTED]> wrote: > > > I don't see how UI lock can be effectively solved using actionscript. It > > > seems to me multithreading in AS would be very fancy, and anything fancy > > > that isn't native just slows things down even more in my opinion. > > > > > > On 12/8/05, Mike Britton <[EMAIL PROTECTED]> wrote: > > > > > > > > It scares me too, but so does UI lock, something that's been happening > > > > to me a lot lately. > > > > > > > > Mike > > > > _______________________________________________ > > > > Flashcoders mailing list > > > > Flashcoders@chattyfig.figleaf.com > > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > > _______________________________________________ > > > Flashcoders mailing list > > > Flashcoders@chattyfig.figleaf.com > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > _______________________________________________ > > Flashcoders mailing list > > Flashcoders@chattyfig.figleaf.com > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders