PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: Peter on October 27, 2007, 01:05:36



Title: Notifications
Post by: Peter on October 27, 2007, 01:05:36
When do I use:

var note:Notification = new Notification();
facade.notifyObservers();

and when
sendNotification();


Title: Re: Notifications
Post by: puremvc on October 28, 2007, 08:39:21
Peter,

If possible, always use sendNotification. Please see the post about the better startup idiom that obviates the need to call notifyObservers from the application:

http://forums.puremvc.org/index.php?topic=85.msg283#msg283

-=Cliff>


Title: Re: Notifications
Post by: Peter on October 28, 2007, 10:02:18
Thanks for the pointer to the article. That works for me too, but,

public function startup( app:Object ):void
{
    notifyObservers( new Notification( STARTUP, app ) );
}

should probably be:

public function startup( app:MovieClip ):Void
{
    notifyObservers( new Notification( STARTUP, app ) );
}

since we are passing the _root timeline as the container for our application?


Title: Re: Notifications
Post by: puremvc on October 28, 2007, 11:32:53
You got it.

-=Cliff>


Title: Re: Notifications
Post by: Peter on November 01, 2007, 03:48:30
About the startup idiom for Flash AS3 applications.
Why not use the base class:

package com.mydomain.myapp {
   
   import flash.display.MovieClip;

   /**
    * @author
    */
   public class StartUp extends MovieClip {
      
      public function StartUp() {
         init();
      }
      
      private function init() : void {
         ApplicationFacade.getInstance().start( this );
      }
   }
}


Title: Re: Notifications
Post by: puremvc on November 01, 2007, 05:42:16
Nothing wrong with that.

-=Cliff>