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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:19:05+00:00 2026-05-21T07:19:05+00:00

I have a custom event that is dispatched when a slider is moved but

  • 0

I have a custom event that is dispatched when a slider is moved but I receive no event from inherited dispatcher class I created whereas I followed the same syntax as solution for My flash custom event doesn't trigger

Event class:

package {

    import flash.events.Event;

     public class CustomEvent extends Event
     {
            public static const ON_DISPATCHER_EVENT = "onDispatcherEvent";
        public var value:Number;

        public function CustomEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false):void
        {
           super(type, bubbles, cancelable);
        }

     }

}

Dispatcher:

package {

    import flash.events.EventDispatcher;
    import flash.events.Event;

    public class CustomEventDispatcher extends EventDispatcher {

        private var cEvent: CustomEvent;      

        public function CustomEventDispatcher() {

        }

        public function raiseEvent(_value:Number) {
            cEvent = new CustomEvent(CustomEvent.ON_DISPATCHER_EVENT);
            cEvent.value = _value;
            dispatchEvent(cEvent);                      
        }

    }
}

Test class:

package {

    import flash.display.*;
    import flash.net.*;
    import flash.events.*;
    import fl.events.SliderEvent;
    import fl.controls.Slider;

    public class TestCustomEvent extends MovieClip {        

      private var cEvent: CustomEvent;

      public function TestCustomEvent() {   

        addEventListener( Event.ADDED_TO_STAGE, init);  

      }

      public function init( e:Event ):void {

        removeEventListener( Event.ADDED_TO_STAGE, init );

        this.addEventListener(CustomEvent.ON_DISPATCHER_EVENT,OnDispatcherEvent);

        slider.addEventListener(SliderEvent.CHANGE,OnSliderEventChange);

      } 


      public function OnDispatcherEvent(event:CustomEvent): void {

            trace(event.value);
      }


      public function OnSliderEventChange(event:SliderEvent) {

            cEvent = new CustomEvent(CustomEvent.ON_DISPATCHER_EVENT);
            cEvent.value = event.value;
            dispatchEvent(cEvent);
                    trace("hello");

      }

    }       
}
  • 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-21T07:19:06+00:00Added an answer on May 21, 2026 at 7:19 am

    I think your understanding of the event flow is a bit off. The answer I already gave in My flash custom event doesn't trigger (that I’m assuming you didn’t read) I think is the proper way to use custom Event and IEventDispatcher objects:

    package 
    {
        import flash.display.Sprite;
        import flash.events.Event;
    
        public class Main extends Sprite 
        {
            private var _sliderSprite:SliderSprite;
    
            public function Main():void 
            {
                if (stage) init();
                else addEventListener(Event.ADDED_TO_STAGE, init);
    
            }// end function
    
            private function init(e:Event = null):void 
            {
                removeEventListener(Event.ADDED_TO_STAGE, init);
    
                _sliderSprite = new SliderSprite();
                _sliderSprite.x = (stage.stageWidth / 2);
                _sliderSprite.y = (stage.stageHeight / 2);
                addChild(_sliderSprite);
    
            }// end function
        }// end class
    
    }// end package
    
    import fl.controls.Slider;
    import fl.events.SliderEvent;
    import flash.display.Sprite;
    
    internal class SliderSprite extends Sprite
    {
        private var _slider:Slider;
    
        public function SliderSprite()
        {
            init();
    
        }// end function
    
        private function init():void
        {
            _slider = new Slider();
            addChild(_slider);
    
            _slider.addEventListener(SliderEvent.CHANGE, onSliderChange);
            addEventListener(CustomEvent.CUSTOM_EVENT_TYPE, onSliderSpriteCustomEventType);
    
        }// end function
    
        private function onSliderSpriteCustomEventType(e:CustomEvent):void
        {
            trace(e.value);
    
        }// end function
    
        private function onSliderChange(e:SliderEvent):void
        {
            dispatchEvent(new CustomEvent(CustomEvent.CUSTOM_EVENT_TYPE, e.value));
    
        }// end function
    
    }// end class
    
    import flash.events.Event;
    
    internal class CustomEvent extends Event
    {
        public static const CUSTOM_EVENT_TYPE:String = "customEventType";
        private var _value:Number;
    
        public function get value():Number
        {
            return _value;
    
        }// end function
    
        public function CustomEvent(type:String, 
                                    value:Number,
                                    bubbles:Boolean = false,
                                    cancelable:Boolean = false)
        {
            _value = value;
    
            super(type, bubbles, cancelable);
    
        }// end function
    
        override public function clone():Event
        {
            return new CustomEvent(type, value, bubbles, cancelable);
    
        }// end function
    
    }// end class
    

    [UPDATE]
    [EDITED 08/04/2011 08:22]

    I’ve modified the code to encapsulate all code involving dispatching and listening to/for events, as well as excuting event handlers, into another class(EventDispatcherManager).

    import flash.display.Sprite;
    import flash.events.IEventDispatcher;
    
    internal class SliderSprite extends Sprite
    {
        private var _slider:Slider;
        private var _eventDispatcherManager:EventDispatcherManager;
    
        public function SliderSprite()
        {
            init();
    
        }// end function
    
        private function init():void
        {
            _slider = new Slider();
            addChild(_slider);
    
            _eventDispatcherManager = new EventDispatcherManager(IEventDispatcher(_slider));
    
        }// end function
    
    }// end class
    
    import fl.controls.Slider;
    import fl.events.SliderEvent;
    import flash.events.EventDispatcher;
    
    internal class EventDispatcherManager extends EventDispatcher
    {
        public function EventDispatcherManager(slider:IEventDispatcher)
        {
            slider.addEventListener(SliderEvent.CHANGE, onSliderChange);
            this.addEventListener(CustomEvent.CUSTOM_EVENT_TYPE, onCustomEventType);
    
        }// end function
    
        private function onSliderChange(e:SliderEvent):void
        {
            this.dispatchEvent(new CustomEvent(CustomEvent.CUSTOM_EVENT_TYPE, e.value));
    
        }// end function
    
        private function onCustomEventType(e:CustomEvent):void
        {
            trace(e.value);
    
        }// end function
    
    }// end function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom even class which is pretty basic. But when calling
I have created custom event like when user is generataed then Event dispatcher will
I have custom event that has several different subscribers who will all use the
I have written a custom Windows Service that writes data to a custom Event
I have a function that I use as a callback for a custom event:
I have a custom event class public class FFTDrawEvent extends Event { public static
I have a custom event that I want to fire using jQuery's trigger method:
I have a static class with a custom event in it, as below: //The
If I have a widget that fires a custom event, and that widget is
Is there a way to have a custom control send events that can be

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.