home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / Beez.swf / scripts / game / model / NotesProxy.as < prev   
Encoding:
Text File  |  2008-09-03  |  1.2 KB  |  59 lines

  1. package game.model
  2. {
  3.    import org.puremvc.as3.interfaces.IProxy;
  4.    import org.puremvc.as3.patterns.proxy.Proxy;
  5.    
  6.    public class NotesProxy extends Proxy implements IProxy
  7.    {
  8.       
  9.       public static const NAME:String = "NotesProxy";
  10.        
  11.       
  12.       private var notes:Array;
  13.       
  14.       public function NotesProxy()
  15.       {
  16.          super(NAME);
  17.          init();
  18.       }
  19.       
  20.       private function init() : void
  21.       {
  22.          notes = [];
  23.       }
  24.       
  25.       private function sendNote() : void
  26.       {
  27.          var note:Object = notes[0];
  28.          if(note.name != GameProxy.UPDATE)
  29.          {
  30.             trace("note!",note.name);
  31.          }
  32.          sendNotification(note.name,note.body);
  33.          sendNoteComplete();
  34.       }
  35.       
  36.       public function push(name:String, body:Object = null) : void
  37.       {
  38.          var note:Object = {
  39.             "name":name,
  40.             "body":body
  41.          };
  42.          notes.push(note);
  43.          if(notes.length == 1)
  44.          {
  45.             sendNote();
  46.          }
  47.       }
  48.       
  49.       private function sendNoteComplete() : void
  50.       {
  51.          notes.splice(0,1);
  52.          if(notes.length > 0)
  53.          {
  54.             sendNote();
  55.          }
  56.       }
  57.    }
  58. }
  59.