Hi Ravi It sounds, like you have a rather good understanding of what is going on. When we talk about the VM, we have to talk about Flash. Flash is framebased like a movie. In every frame all the scripts of all movieclips are executed, then all the system events are handled, be it load, timer, key or mouse events, and finally, the screen is updated. This loop is repeated all the time. And yes, no script is ever interrupted, so big operations block your whole system.
If you want to execute huge operations without blocking, you have to split this operation up into multiple parts and use a timer to execute the parts of this operation one by one. Personally, i wouldn't want to introduce such a complicated and much disputed low level mechanism as threads intro the flash/flex programming model. Cheers Ralf. On 2/22/07, ravi kumar gummadi <[EMAIL PROTECTED]> wrote:
Hi, I am basically a Java guy, recently into Flex. It may be due to the sudden paradigm shift from serial programming ( incl Threads) to Event Based Programming, that I find many features totally new and surprising. I read in a article that Flash/Flex is based on AMPED (Asymmetric-Multi Process Event Driven) Architecture. In this kind of architecture , We have a single thread dispatching the events and the control gets transferred between the Events and the main thread. ( These are my vague conclusions from what I have read and understood, Correct me if I am wrong! ) So if the event dispatched doesn't have a IO/Network operation, the control reaches back to the EventDispatcher only after the eventhandler method is totally complete. But if our eventhandling mechanism has a huge data crunching operation , doesn't that freeze the client? 1. Lets say I have 2 things to be done, Doing a animation and some huge data operation simultaneously! In Java, what we usually do is spawn a new thread for doing the animation (or) doing the data operation! This takes care of the scenario. Now in Flex, We dispatch events, Lets say, OperateDataEvent and AnimateEvent, both of them have some handlers (ODEHandler, AEHandler respectively). Now when we do something like this, dispatchEvent(new OperateDataEvent()) and dispatchEvent(new AnimateEvent()) How does the control flow?? Does this fully complete the DataOperationEvent first and then return to animateEvent ! Since its a single thread model, I guess it should be done so! But then it doesnt sound logical for any matured programming languge to cripple an application from doing another task and make it wait. 2. Second thing is, How does the Timer/setInterval actually function in the Flex architecture, Is it a separate 'thread' ( Oops!this Java hangover is not gonna leave me ! ) Is it advisable to have big operations inside the timerHandler which may result in periodic glitches in the application. 3 Can anyone give a good resource of the AVM structure and design and how it differs from JVM! Thanks in advance Cheers, Ravi Kumar G PartyGaming Plc. www.partygaming.com "What is right is right, even if no one is doing it. What is wrong is wrong, even if everyone is doing it." ------------------------------ Never miss an email again! Yahoo! Toolbar<http://us.rd.yahoo.com/evt=49938/*http://tools.search.yahoo.com/toolbar/features/mail/>alerts you the instant new Mail arrives.Check it out.
-- Ralf Bokelberg <[EMAIL PROTECTED]> Flex & Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35

