7 Replies Latest reply on Aug 22, 2011 3:27 AM by nikos101

    quick parsely question

    nikos101 Level 2

      how do I call the init after injection?

       

        [Bindable]
              public var tradesModel:TradesModel;

       

             
               private function init():void {
                  tradesModel.tradesBackOffice.filterFunction = tradeFilterFunction;
                  tradesModel.tradesBackOfficeModified.add(updateTradeList);

              }

        • 1. Re: quick parsely question
          Claudiu Ursica Level 4

          You have 2 options:

           

          1. mark method with and make it public.

           

          2. make setter foe model and do it by hand inside setter after verifying that the value to be set is not null...

           

          C

          • 2. Re: quick parsely question
            nikos101 Level 2

            cool, so init is called by parsely

             

            cant do the latter cause my filter function depends on the view

             

            which parsely supported signals as messages ):) i hate strings

            • 3. Re: quick parsely question
              artguate Level 2

              Parsley has a very powerful messaging system.  It's not exactly like Signals, but it's not dependant on Strings.

               

              Take a look at:

              http://artinflex.blogspot.com/2010/09/quick-dive-into-parsley-basic-messaging.html

              • 4. Re: quick parsely question
                Karl_Sigiscar_1971 Level 3

                Parsley messaging is based on the event class, but you can also add a selector to the [MessageHandler] metadata tag, in order to differentiate between messages of the same class but of a different type: [MessageHandler(selector="close"] for e.g an OpenCloseEvent class:

                 

                 

                public class OpenCloseEvent {

                ...

                     public static const OPEN:String = "open";

                     public static const CLOSE:String = "close";

                ...

                }

                 

                 

                [MessageHandler(selector="open")]

                public function openMessageHandler(event:OpenCloseEvent) {}

                 

                [MessageHandler(selector="close")]

                public function closeMessageHandler(event:OpenCloseEvent) {}

                 


                I personally use Parsley messaging where it makes sense: when one or both of the dispatching and receiving objects are not in the display list or if the dispatcher and receiver are sibblings in the display list (meaning the receiver is in an inaccessible area for bubbling). Parsley messaging is also very useful when you need to communicate between modules, or between the main application and modules or between the main application and a popup window.

                 

                When for example, you have an item renderer dispatching an event that must be caught by a List based component or by the component that instantiate the List based component, event bubbling totally makes sense.

                • 5. Re: quick parsely question
                  artguate Level 2

                  @ Karl

                   

                  That is incorrect.  Well, depends on what you mean by "based", but for practicall purposes, that is not correct.

                   

                  Parsley allows you to send "messages" that do not extend the Event class.  You can dispatch basically any class you want, and does not requiere to have a "type" selector.

                   

                  Look at the link I posted above, you can see a simple example.

                   

                  Regards,

                   

                  -Art

                  1 person found this helpful
                  • 6. Re: quick parsely question
                    Karl_Sigiscar_1971 Level 3

                    I use Parsley daily.

                     

                    When I say "Parsley messaging is based on the event class", I mean the custom Parsley message class or Parsley notification class or Parsley event class type is used by the Parsley messaging system as opposed to just a String. I do not imply that your custom message class needs to extend flash.events.Event. I am fully aware that you only need to extend Event when you use dispatchEvent as opposed to the injected Parsley dispatcher function.

                     

                    It doesn't matter if you call it a message, a notification or an event.

                     

                    A caveat you need to be aware of, the message handler function marked with [MessageHandler] has to be public. If it's private, you will not get the handler called.

                    • 7. Re: quick parsely question
                      nikos101 Level 2

                      thx guys