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

  • Home
  • SEARCH
  • 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 6760923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:07:22+00:00 2026-05-26T14:07:22+00:00

I have the following situation: I have an event handler, that displays small messages

  • 0

I have the following situation:

I have an event handler, that displays small messages in my application’s statusbar.
These messages get passes through by dispatching events from custom components.
A simple message could be like “HTTP Error” or so.

Now, the main event listener, in the main application file, listens to the event dispatched by any custom component, but seems to refuse listening to events dispatched by custom AS classes.

Here is my code for the custom event:

package main.events
{
    import flash.events.Event;

    public class ShowNoticeEvent extends Event
    {
        public var message:String;
        public static const SHOW_NOTICE:String = "showNotice";

        public function ShowNoticeEvent(type:String, msg:String, bubbles:Boolean = false, cancelable:Boolean = false)
        {
            super(type, bubbles, cancelable);
            this.message = msg;
        }

        override public function clone():Event
        {
            return new ShowNoticeEvent(type, message);
        }
    }
}

This is the event listener in the main application file:

addEventListener(ShowNoticeEvent.SHOW_NOTICE, showNoticeListener, true);

And this is the custom AS class that dispatches the custom event. I pasted all the code, so you could see the whole part of it.

   package components.dashboard
{
    import components.dashboard.models.*;

    /* Event imports */
    import flash.events.*;
    import main.events.*;

    import mx.controls.Alert;
    import mx.core.UIComponent;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.http.HTTPService;

    [Event(name="showNotice", type="main.events.ShowNoticeEvent")]
    public class Controller extends UIComponent
    {
        private var baseUrl:String;

        public function Controller(baseUrl:String)
        {
            this.baseUrl = baseUrl;
        }

        public function getRunningQuotations():void
        {
            var runningQuotationsList:RunningQuotationsList = RunningQuotationsList.getInstance();

            execService("index.php?a=1", runningQuotationsList.updateList, "pnlRunningQuotations"); 
        }

        public function getRecentProjects():void
        {
            var recentProjectsList:RecentProjectsList = RecentProjectsList.getInstance();

            execService("index.php?a=2", recentProjectsList.updateList, "pnlRecentProjects");
        }

        public function getLatestCustomers():void
        {
            var latestCustomersList:LatestCustomersList = LatestCustomersList.getInstance();

            execService("index.php?a=3", latestCustomersList.updateList, "pnlLatestCustomers");
        }

        private function execService(url:String, listener:Function, component:String):void
        {
            var basicService:HTTPService = new HTTPService(baseUrl);
            basicService.showBusyCursor = true;
            basicService.addEventListener(FaultEvent.FAULT, function(e:FaultEvent):void{httpFault(e, component)});
            basicService.method = "POST";
            basicService.resultFormat = "text";
            basicService.url = url;
            basicService.addEventListener(ResultEvent.RESULT, listener);
            basicService.send();            
        }

        private function httpFault(event:FaultEvent, component:String = null):void {
            var faultstring:String = event.fault.faultString;
            var eventObj:ShowNoticeEvent = new ShowNoticeEvent(ShowNoticeEvent.SHOW_NOTICE, faultstring, true); 

            dispatchEvent(eventObj);
            trace(faultstring);
        }
    }
}

So to sum it all up:
– The event listener listens to the custom event dispatched by any custom component.
– The event listener does not listen to the custom event duspatched by an AS class.

Those who wonder, the event really gets dispatched, that’s why I added a trace call.

  • 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-26T14:07:23+00:00Added an answer on May 26, 2026 at 2:07 pm

    The instance of Controller Class would have to be added to stage for that to work.

    by doing

    addEventListener(ShowNoticeEvent.SHOW_NOTICE, showNoticeListener, true);
    

    in the main file you are adding the listener to the stage.

    So basically you are doing.

    stage.addEventListener(ShowNoticeEvent.SHOW_NOTICE, showNoticeListener, true);
    

    If controler instance is not on stage you won’t see the event.

    You might want to look into a Singleton type pattern for your data management as that would fit this setup pretty good.

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

Sidebar

Related Questions

I have the following situation: a class Event that has a collection of Participant
My situation is the following: I have a template wrapper that handles the situation
I've recently come across the following situation. I have a UserControl that can show
please consider the following scenario for .net 2.0: I have an event that is
I have following situation class base { public: virtual void Accepted(SOCKET s) //// Event
I have following situation in a C# Windows Forms (.NET 4.0) application: I have
I have following situation - Have a MongoService class, which reads host, port, database
I have following situation. In a constructor of a pseudo class I attach a
I have following situation (simplified, of course): MyDomain.groovy: class MyDomain { MyAnotherDomain anotherDomain //
I have following situation, String a=<em>crawler</em> <em> Yeahhhhh </em></a></h3><table; System.out.println(a.indexOf(</em>)); It returns the 11

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.