Search code examples
actionscript-3apache-flexevent-handlingparsley

Parsley MessageHandlers not working


I am creating a sample MVC using Parsley Framework of Flex. I am having one slider control (mx:HSlider) which dispatches the event to the model for doing something on slider change. For that i have created one custom event and i am using parsley selectors for handling event. Here is the code

//Event
        class MyEvent extends Event
        {
        public static const MSG="msg";
    //constructor, clone method and two fields
        }

//View
    <fx:Metadata>
    [Event name="msg" type="pack1.MyEvent"]
    [ManagedEvents("msg")]
    </fx:Metadata>

    <fx:Declaration>
    <parsley:Configure/>
    </fx:Declaration>

    public function onSliderChange(event:SliderEvent):void
    {
    dispatchEvent(new MyEvent(MyEvent.MSG,event.thumbIndex,event.value);
    }

//Model
    [MessageHandler(selector="msg")]
    public function doSomething(event:MyEvent)
    {
    //code
    }

Now, event gets dispatched successfully but somehow message handler is not getting called. What can be wrong here? Can anyone please make me know what is problem? Any kind of help will be appreciated. Thanks in advance.

Note : My context is getting initialized and my model is also getting injected. But the events shows me some strange behaviour. It is just not getting dispatched to the model where handlers for that are.


Solution

  • I thought there is an error in some configuration or in normal events with parsley events but in my code i was dispatching more that one events from the class and i was writing them as

    [ManagedEvents("a","b","c")]
    

    But after reading documentation of parsley i observed that it should be

    [ManagedEvents("a,b,c")]
    

    It solved my problem. Thanks for all your replies.