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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:16:12+00:00 2026-05-24T16:16:12+00:00

I want to have a single event listener for multiple events and depending on

  • 0

I want to have a single event listener for multiple events and depending on the
type of event i want to handle them separately.

Something similar to Swiz framework see: ‘Handling Multiple Events from a Single Method’

i have a piece of code like

     var toolOptions:UIComponent=ToolOptions.createToolOptions(type);
            if (options != null)
            {
                options.addEventListener(Event.SELECT,toolOptionSelectedHandler);
                someViewComponent.addOptions(toolOptions);
            }

   // handle depending on event type
    private function toolOptionSelectedHandler(event:*):void
    {
        //handle depending on type of event fired
        // type cast  event depending on type and  retrieve VO from event 
        //and send handle it..

        //SomeToolObj.handle(event.VO);    

    }

In above toolOptions is a mxml component which get dynamically created based on
‘type’.

Also which type of event should be dispatch the event from the component? eg: Event.SELECT

To be more precise the above is basically required for a toolbar.
When user selects a tool,he is shown options for a tool and when he selects options,
tool should apply them to object on the view.

Is there a better way to do the same?

  • 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-24T16:16:13+00:00Added an answer on May 24, 2026 at 4:16 pm

    That’s what I understand:

    You have different tools. Each of the tools has a list of options. You click an option, and a single event handler should perform some action depending on the option.

    object on the view 1 : n tools 1 : n options
    

    Create a custom event OptionEvent.SELECT with the property optionType.

    public class OptionEvent extends Event {
        public static const SELECT : String = "optionEvent_select";
        public var optionType : String;
        public function OptionEvent(type : String) {
            super(type, true); // bubbles
        }
    }
    

    When the user selects the option, dispatch the event like this:

    var event : OptionEvent = new OptionEvent(OptionEvent.SELECT);
    event.optionType = "border";
    dispatchEvent(event);
    

    Listen to the event like you do:

    var toolOptions:UIComponent=ToolOptions.createToolOptions(type);
    if (options != null) {
        options.addEventListener(OptionEvent.SELECT,toolOptionSelectedHandler);
        someViewComponent.addOptions(toolOptions);
    }
    

    Distinguish the type of option by determining the option type:

    private function toolOptionSelectedHandler(event : OptionEvent) : void {
         var optionType = event.optionType;
         switch (optionType) {
             case "border":
                 addBorderToView();             
                 break;
             case "rotation":
                 rotateView();             
                 break;
         }
    }
    

    UPDATE – How to set up a list of option values in OptionEvent:

    public class OptionEvent extends Event {
        public static const SELECT : String = "optionEvent_select";
        public var optionType : String;
        private var _optionValues : Object;
    
        public function OptionEvent(type : String) {
            _optionValues = new Object();
            super(type, true); // bubbles
        }
    
        public function setOptionValue(property : String, value : *) : void {
            _optionValues[property] = value;
        }
    
        public function getOptionValue(property : String) : * {
            return _optionValues[property];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database of events which gets updated every night. A single event
I want to have a single lined TextView to show up 3 dots at
I have a single big text file in which I want to process each
I have a single XML file that I want to index using Lucene.NET. The
I want to have some kind of single list that is initialized in a
I want to have on my site a single select box that will then
Basically I have a single page on my site that I want any php
I have implemented Single-Sign-On in my iOS 4.3 app successfully. Now I want to
** I want one single list item to have fistname, last name and the
I have a timestamp and I want to search for a single date but

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.