Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 261713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:27:18+00:00 2026-05-11T22:27:18+00:00

I have been trying to understand the way ActionScript’s events are implemented, but I’m

  • 0

I have been trying to understand the way ActionScript’s events are implemented, but I’m stuck.

I know that AS is single threaded, which means that only one event handler will be executing at a time, and also means that handlers will be executed in a deterministic order*.

For example, consider the following code:

1: var x = {executed: false};
2: foo.addEventListener("execute", function(){ x.executed = true; });
3: foo.dispatchEvent(new Event("execute"));
4: assert(x.executed);

If ActionScript was multi-threaded, it would be possible that the assertion on line 4 could fail sometimes and succeed others.

But since AS is not multi-threaded, it stands to reason that the assertion will either always fail² or always succeed³. Or, in other words, events will be handled in a deterministic way.

So, is this assumption (that events hare handled deterministically) correct? Does Adobe provide any definitive documentation on the matter?

Note: I am only concerned here with events dispatched by dispatchEvent – I realize that “externally dispatched” events (network traffic, user input, timers ticking, etc) behave differently.


*: with the exception, of course, for events triggered by nondeterministic things like user input or network traffic.
²: it would always fail if, for example, if the event handling algorithm was: “push new events onto a stack, then continuously pop the top event off the stack, execute it until it terminates, then go on to the next event”.
³: it would always succeed if events dispatched by dispatchEvent were handled as soon as they were dispatched.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:27:18+00:00Added an answer on May 11, 2026 at 10:27 pm

    Unless I’m misunderstanding — in which case I do apologize! — I have to disagree with the others: you need only test the code you’ve submitted to see the value of x.executed traces true every time.

    For example, if, in place of your foo object, you were to substitute an IEventDispatcher (in this case I do so implicitly, with my app object and its creationComplete handler), you’d see:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()">
    
        <mx:Script>
            <![CDATA[
    
                private function onCreationComplete():void
                {
                    var x = {executed: false};
                    addEventListener("execute", function() { x.executed = true; });
                    trace(x.executed); // false
                    dispatchEvent(new Event("execute"));
                    trace(x.executed); // true
                }
    
            ]]>
        </mx:Script>
    
    </mx:WindowedApplication>
    

    Of course, there are ways of controlling event-handling order (using the priority argument of addEventListener), and various phases of event propagation for objects on the display list (e.g., capturing, targeting, bubbling — see the Flex docs for detailed information, here and here), but in this kind of situation, events are indeed handled essentially inline and in priority order. According to the docs:

    Flex registers event listeners in the
    order in which the addEventListener()
    methods are called. Flex then calls
    the listener functions when the event
    occurs in the order in which they were
    registered. However, if you register
    some event listeners inline and some
    with the addEventListener() method,
    the order in which the listeners are
    called for a single event can be
    unpredictable.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand this is a basic question... but I have been stuck on it
I have been trying to understand a bit more about the wider picture of
I have been trying to find a really fast way to parse yyyy-mm-dd [hh:mm:ss]
I have been trying to work my way through Project Euler, and have noticed
I have been trying to learn multi-threaded programming in C# and I am confused
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to determine a best case solution for registering a COM
I have been trying to get around this error for a day now and
I have been trying to explain the difference between switch statements and pattern matching(F#)
I have been trying to read a picture saved in Access DB as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.