2 Replies Latest reply on Sep 17, 2010 3:17 AM by Whitetimer

    Custom Event Error Help

    Whitetimer Level 1

      Hi All

       

      I have a Custom Event

       

      package Events
      {
           import flash.events.Event;
           
           public class NavigationEvent extends Event
           {
                public var buttonID:String;
                
                public function NavigationEvent(type:String, buttonID:String)
                {
                     //
                     super(type);
                     this.buttonID = buttonID;
                }
                
                override public function clone():Event
                {
                     return new NavigationEvent(type, buttonID);
                }
           }
      }
      

       

      That i am using within a Custom Component

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                             xmlns:s="library://ns.adobe.com/flex/spark" 
                             xmlns:mx="library://ns.adobe.com/flex/mx"
                             width="275" height="300">
           
           <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           </fx:Declarations>
           
           <fx:Metadata>
                [Event(name="Navigation", type="Events.NavigationEvent")]
           </fx:Metadata>
           
           <fx:Script>
                <![CDATA[
                     import Events.NavigationEvent;
                     
                     private function buttonClickHandler(event:NavigationEvent):void
                     {
                          var eventObj:NavigationEvent = new NavigationEvent("Navigation", event.target.id);
                          dispatchEvent(eventObj);
                     }
                     
                ]]>
           </fx:Script>
           
           <s:BorderContainer width="230" height="24" backgroundColor="#00688B" cornerRadius="11" borderVisible="true" borderColor="#FFFFFF">
                <s:layout>
                     <s:VerticalLayout horizontalAlign="center" verticalAlign="middle" />
                </s:layout>
                <mx:LinkButton id="homeBTN" width="224" height="18" label="Home" cornerRadius="9" color="#FFFFFF" textAlign="center" click="buttonClickHandler(event)" />
           </s:BorderContainer>
           
      </s:BorderContainer>
      

       

       

      But i am getting this error message

       

      Description     Resource     Path     Location     Type
      1067: Implicit coercion of a value of type flash.events:MouseEvent to an unrelated type Events:NavigationEvent.     Comp_Navigation.mxml     /uwth1/Components     line 28     Flex Problem
      
       
      

       

      How do i correct this please ?

       

      Many Thanks