Custom Events and Event Handlers

I have setup up a EventDispatcher interface on an Abstract Object.  I am trying to call an event handler in the inherated object.  All of the code compiles and works, but the event will not fire.

How do you fire events from within objects.  What have I done wrong?

===================================================================================
Abstract Class, Base Object
===================================================================================
package EasterEggDesigner.DesignTools
{
      import flash.display.*
      import flash.events.*;
      import flash.net.*;
      
      public class DesignTool extends MovieClip implements IEventDispatcher
      {
            private var _IconFile:String;
            private var _IconLoader:Loader = new Loader();
            
            public static const ICON_CHANGED:String = "IconChanged";
            public static const BASE_LOADED:String = "BaseLoaded";
            
            private var dispacher:EventDispatcher = new EventDispatcher();
            
            public function set IconFile(newFile:String)
            {
                  _IconFile = newFile;
                  
                  //
                  // ABDC_TODO: Set golbal File directory
                  //
                  
                  var FileRequest:URLRequest = new URLRequest("ToolIcons/" + newFile);
                  _IconLoader.load(FileRequest);
                  addChild(IconLoader);
                  dispacher.dispatchEvent(new Event(ICON_CHANGED));
            }
            
            public function get IconFile():String
            {
                  return _IconFile;
            }
            
            public function get IconLoader():Loader
            {
                  return _IconLoader;
            }
            
            public function DesignTool()
            {
                  dispacher.dispatchEvent(new Event(BASE_LOADED));
            }
      }
}

===================================================================================
Child Class
===================================================================================

package EasterEggDesigner.DesignTools
{
      import flash.display.*;
      import flash.events.*;
      import flash.text.*;
      
      public class Sizer extends DesignTool
      {      
            public function Sizer()
            {
                  txtToolName.text = "Sizer";
                  IconFile = "Sizer.swf";
                  addEventListener(ICON_CHANGED,onIconChange);
            }
            
            public function onIconChange(event:Event):void
            {
                  trace("The Icon Has Been Loaded" + event.target);
            }
      }
}
hoyaabanksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

trigger-happyCommented:

 public class DesignTool extends MovieClip implements IEventDispatcher
      {
            private var _IconFile:String;
            private var _IconLoader:Loader = new Loader();
            
            public static const ICON_CHANGED:String = "IconChanged";
            public static const BASE_LOADED:String = "BaseLoaded";
            
            private var dispacher:EventDispatcher;
            
            public function set IconFile(newFile:String)
            {
                  _IconFile = newFile;
                  
                  //
                  // ABDC_TODO: Set golbal File directory
                  //
                  
                  var FileRequest:URLRequest = new URLRequest("ToolIcons/" + newFile);
                  _IconLoader.load(FileRequest);
                  addChild(IconLoader);
                  dispacher.dispatchEvent(new Event(ICON_CHANGED));
            }
            
            public function get IconFile():String
            {
                  return _IconFile;
            }
            
            public function get IconLoader():Loader
            {
                  return _IconLoader;
            }
            
            public function DesignTool()
            {
                  dispacher = new EventDispatcher();
                  dispacher.dispatchEvent(new Event(BASE_LOADED));
            }
      }
}
 
package EasterEggDesigner.DesignTools
{
      import flash.display.*;
      import flash.events.*;
      import flash.text.*;
      
      public class Sizer extends DesignTool
      {      
            public function Sizer()
            {
                  super();
                  txtToolName.text = "Sizer";
                  IconFile = "Sizer.swf";
                  addEventListener(ICON_CHANGED,onIconChange);
            }
            
            public function onIconChange(event:Event):void
            {
                  trace("The Icon Has Been Loaded" + event.target);
            }
      }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.