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 165217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:52:56+00:00 2026-05-11T11:52:56+00:00

Does anyone have experience in hooking onto events. so we can modify there behavior

  • 0

Does anyone have experience in hooking onto events. so we can modify there behavior without changing it’s initial.

So lets say we want to modify the behavior of every click of a certain set of menu buttons that if you click them you would wait 30 seconds before the original callback is called.

I’m working on a project that will create a layer on top of an existing Air application that will allow to Manage to build in a way to allow micro-payments to enable full access to certain features.

And my guess was to use hooking for capturing your events, so we don’t have to edit our application but just extend it. (correct me if I’m wrong :-))I

  • 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. 2026-05-11T11:52:56+00:00Added an answer on May 11, 2026 at 11:52 am

    Yes, that should be posible with some modification.

    Instead of dealying the event, you can stop it before it reaches it’s original target, clone it and then refire the clone after the delay.

    If you don’t know how events work in the displaylist (anything you can see) in flash let me first explain it.

    When you click a button a MouseEvent is fired, it begin in the capturing fase where it starts on the stage calling all eventlisteners registered for the ‘CLICK’ event in the order of the priority set when the listeners was registered. If listerners has the same priority (the default is 0), the are called in a random order (properly the order that they where registered). Once all listeners for the stage has been called the next displayObject in the list of the buttons ancestors is called, and the same thing happens again. This continue all the way down to inner most displayobject that allow mouse events (could be a textfield label inside the button). Here the capturing phase ends and the target phase begins. The all the listeners on the innermost object is called in the target phase. Then the bubbling phase begin, where all the listernes are called on parents and grandparents all the way up to the stage in the same manner as before (but from the inside out).

    It should be noted that in flash the target phase is handled as part of the bubbling phase.

    And how can we use this?

    Well when you register and event listener you specify the phase and priority. The defaults are bubbling phase and priority 0. So if we register a click event listener on the stage for the capturing phase with priority int.MAX_VALUE, we would get the event before any other listerne except perhaps another identical listener. The following code would prevent click events to registered by other listeners.

    stage.addEventListener(MouseEvent.CLICK, stageClick, true, int.MAX_VALUE);  function stageClick(e:MouseEvent):void {     e.stopImmediatePropagation(); } 

    That raises some other problems, firstly you don’t want to do it for everything.

    • One solution would be be to have a list of all buttons that should have their events modified, and checking against it with e.target.
    • Another solution would be to have all buttons that require a delay implement an interface (lets call it IButtonDelay). And then simple check if e.target is IButtondelay.
    • A third solution would be to only listen for the events on a containg parent (like a menubar), since it is unlikely that you would use the event before it reaches this parent anyway.

    For the first two solutions you should prevent mouseinteraction for the children of the buttons to simplify detection (DisplayObjectContainer.mouseChildren = false). No matter what you choose here, next you would have to delay with a simple Timer. And then fire the event again after the delay.

    e.target.dispatchEvent(e.clone()); 

    That raises the problem of not delaying the refired event. My suggestion would be to instead fire an event object that inherits from MouseEvent instead of a simple clone. The MouseEvent is very simple to copy, it only has a few properties. So when you capture it the second time you can check if its a normal mouse click or your duplicated.

    Using the solution with the inface on the buttons, it would be something like:

    stage.addEventListener(MouseEvent.CLICK, stageClick, true, int.MAX_VALUE);  function stageClick(e:MouseEvent):void {     if(e.target is IDelayButton && !e is DelayedMouseEvent)     {         e.stopImmediatePropagation();         DelayEvent(e);     } }  function DelayEvent(e:MouseEvent):void {     //You code for the delaying, cloning and refiring the event here } 

    You might need to listen for more types of events (keyboard events), but most of the code can be made generic enough to include them.

    Hope that helps and sorry about the long read.

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

Sidebar

Ask A Question

Stats

  • Questions 279k
  • Answers 279k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First, PowerShell functions return all uncaptured "output". You can capture… May 13, 2026 at 3:24 pm
  • Editorial Team
    Editorial Team added an answer Convert them to Sets and use removeAll. The first problem… May 13, 2026 at 3:24 pm
  • Editorial Team
    Editorial Team added an answer SharpMap is a (well known and used) OpenSource collection of… May 13, 2026 at 3:24 pm

Related Questions

I have a simple C# application that uses UDP multicast in a single-receiver, single-sender
We have an application that will be collecting data and storing it in local
I need to make call to a WCF service in a Transaction scope. I
I'm exploring the possibility of writing an application in Erlang, but it would need

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.