3 Replies Latest reply on Apr 8, 2009 1:31 PM by Flex harUI

    Using constants to name events?

    peteandrus Level 1

      i am creating custom Flex components using Actionscript. I have a compoent called 'reportAccordion' (real class names have been changed to protect the innocent) that extends Accordion. I am trying to add an attribute:

       

      [Event(name="myReportWasClicked",type="jsurs.events.ReportList.myReportDisplayerClickEvent ")]

       

      if i do it with the above code, then when i'm tying it all together in my MXML file, I add a 'reportAccordion' object and reference the 'myReportWasClicked' event and assign an action for it no problem. However, i would like to be able to make the event type a constant so that the class that dispatches it and the attribute declaration will always be in sync. Is this possible? I added a constant to the myReportDisplayerClickEvent class:

       

      public static const myReportClickType:String         = "myReportWasClicked"; //the actual value of the type should be arbitrary...

       

      However, if i try this:

       

      [Event(name=JSURSReportDisplayerClickEvent.myReportClickType,type="jsurs.events.ReportList .JSURSReportDisplayerClickEvent")]

       

      Then i cannot access the 'myReportWasClicked' event in the list. It does not exist. If i add it manually, i get an error that it does not exist.

       

      How can i use the constant to specify the Event type in the attribute's name field?

       

      thanks!