/6/ code structure: a MessageDialog example
// PACKAGE
AsSetupPackage("org.moock.ui");

// CLASS MessageDialog EXTENDS MovieClip

/**
 * A very simple "Message" dialog box example that displays
 * a message and an OK button. The assets for this class
 * live in the MessageDialog Library symbol. This class is
 * an example only. It does not handle real world features
 * like depth management or sending feedback when it is closed.
 */
org.moock.ui.MessageDialog = function () {
  // Empty because this is a MovieClip subclass. See init().
}

// SET SUPERCLASS
org.moock.ui.MessageDialog.prototype = new MovieClip();

// PROPERTIES
  // A text field to display the dialog's message.
  org.moock.ui.MessageDialog.prototype.msg_txt = null;

  // A text field to display the dialog's title.
  org.moock.ui.MessageDialog.prototype.title_txt = null;

  // The dialog box title bar.
  org.moock.ui.MessageDialog.prototype.titleBar_mc = null;

  // The "OK" button.
  org.moock.ui.MessageDialog.prototype.ok_btn;

  // The "Close" button (little 'x' icon).
  org.moock.ui.MessageDialog.prototype.close_btn;

// METHODS
  /**
   * Initializes the dialog box.
   *
   * @param   title   The title to display in the title bar.
   * @param   message   The message to display in the dialog box.
   * @param   x   The initial horizontal position for the dialog box.
   * @param   y   The initial vertical position for the dialog box.
   */
  org.moock.ui.MessageDialog.prototype.init = function (title, 
                                                        message,
                                                        x,
                                                        y) {
    // Display title.
    this.title_txt.text = title;
    // Display message.
    this.msg_txt.text = message;

    // Position the dialog.
    this._x = x;
    this._y = y;

    // Now assign button behaviors...

    // Drag the dialog when the title bar is pressed.
    this.titleBar_mc.onPress = this.dragDialog;
    // Drop the dialog when the title bar is released.
    this.titleBar_mc.onRelease 
          = this.titleBar_mc.onReleaseOutside 
          = this.dropDialog;
    // Close the dialog when the ok button is clicked.
    this.ok_btn.onRelease = this.closeDialog;
    // Close the dialog when the close button is clicked.
    this.close_btn.onRelease = this.closeDialog;
  }

  /**
   * Makes the dialog follow the mouse.
   */
  org.moock.ui.MessageDialog.prototype.dragDialog = function () {
    this._parent.startDrag();
  }

  /**
   * Stops the dialog following the mouse.
   */  
  org.moock.ui.MessageDialog.prototype.dropDialog = function () {
    stopDrag();
  }

  /**
   * Removes the dialog from the screen.
   */
  org.moock.ui.MessageDialog.prototype.closeDialog = function () {
    this._parent.removeMovieClip();
  }
#initclip
Object.registerClass("MessageDialog", org.moock.ui.MessageDialog);
#endinitclip
// CODE ON FRAME 1
#include "../org/moock/lang/AsSetupPackage.as"
#include "../org/moock/ui/MessageDialog.as"

// FRAME 2 CONTAINS A DUMMY INSTANCE OF THE MessageDialog SYMBOL

// CODE ON FRAME 3
stop();

// Example Dialog Box
this.attachMovie("MessageDialog", "message_mc", 0);
this.message_mc.init("Important Information", 
                     "Thank you for reading this message...", 
                     135,
                     150);