----- Original Message ----- From: "Ralf Bokelberg" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Tuesday, December 09, 2008 3:00 PM Subject: Re: [flexcoders] Re: Parsley MVC :: some thoughts
> Hi Amy > > Afaik this is not possible in Flashplayer. A block of code is always > running through without any interuption. I think this has been part of the discussion in the thread. While it is what I would expect, if dispatching events causes all listening event handlers to be called synchronously, it means that any block of code dispatching an event is going to be interrupted and potentially "unknown" event listeners called during the execution of that code block. Here's an interesting scenario: If I have a block of code building a data structure and it has an object reference to some model. It could be that it encounters some situation and dispatches an event. The event handler may then interrogate the model, modify the model and control then returns to the executing block which is then unaware of the model change and still iterating through the model. My expectation would be that dispatch event would add the event to a queue of events ready to be handled, but those would not be handled until the code block had completed. In other systems/languages my code blocks would include semaphore handling to protect such data structures, but there's no option for me to do that in actionscript. You may argue that the developer should 'know' what may potentially happen when writing code and despatching events, but in practice who knows who may add a new event handler to the application in future and may introduce a problem. I don't have a problem with all event handlers being called when an event is fully despatched, but that's potentially dangerous if it's done in the middle of a code block. Anyway it's just a thing to keep in mind. I would agree that it's a marginal and unlikely scenario. Paul >Colin Moock has a good > chapter of how all this works in his nice AS3 book. > > Cheers > Ralf. > > > > On Tue, Dec 9, 2008 at 3:44 PM, Amy <[EMAIL PROTECTED]> wrote: > >> I actually had this very thing happen in my code a couple of weeks >> ago. I normally expect that the code in a function will all run as a >> block unless, of course, I'm calling out to another function. But in >> one case, one of the statements I was using (addEventListener, I >> think), opened up enough of a timing "hole" in my code that some >> other code (not the function that was being added in the event >> listener, which might have been partially understandable) ran >> unexpectedly at that point. The only solution I found was to make >> sure I put all of the other code that _had_ to run in that block >> before anything else happened above the addEventListener code. >> >> -Amy > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > >

