2 Replies Latest reply on Sep 9, 2008 3:38 PM by 234123412334

    Event Generation

      In the Creating custom events, the author said that after defining custom, and typing the name of the event in the component tag, the event handler was dynamically created in the Script section of the code. I tried to reproduce this and failed. What is needed to automatically create event handler functions?
        • 1. Re: Event Generation
          Are you using Flex Builder 3 or another IDE? In Builder, it will usually automatically add in import statements as you code.

          For example, let's say you're making a resultHandler event with the HTTPService.

          If you add this function:

          private function resultHandler(e:FlexEvent)
          //My code here

          Flex Builder will automatically add:

          import mx.events.FlexEvent;

          at the top of your <mx:Script> block

          If you're still having problems, you're welcome to post your code here.
          • 2. Event Generation
            234123412334 Level 1
            I am using Flex Builder 3.0.205647.

            I placed the following in a Profile.mxml file.
            [Event(name="optionSelected", type="events.OptionSelectEvent")]

            private function clickHandler(event:Event):void{
            var selection:String = event.target.label;
            var optionSelectEvent:OptionSelectEvent = new OptionSelectEvent("optionSelected",getSummary());


            Then and another mxml file I place a markup tag for that component.

            <local:Profile id="ProfileComponent" optionSelected="clickHandler(event)" width="339" height="131" x="10" y="323"/>

            When I starting typing optionSelected .. I control spaced and it completed the optionSelected.method. The clickHandler() method does not get generated in the script section as it does in the Create Custom events at 5:17 seconds