Document class for the movie
package
{
import flash.display.Sprite;
import flashscriptMVC.AbstractClass;
import flashscriptMVC.IModel;
import flashscriptMVC.Model;
import flashscriptMVC.Controller;
import flashscriptMVC.views.LoginView;
import flashscriptMVC.views.AlertView;
import flashscriptMVC.IControlHandler;
public class Main extends Sprite
{
public function Main ():void
{
/*
* We create instances of the model, controller and the two viewers.
* The Model constructor has one argument for the url of an XML file,
* which contains all the data necessary to run the Login module. There are
* two viewers, one for the Login and one for the Alert, when errors have
* occurred.
*/
var model:IModel = new Model("login.xml");
var controller:IControlHandler = new Controller(model);
var view:AbstractClass = new LoginView(model,controller);
view.x = 50
view.y = 150;
addChild (view);
//
// Adding the second viewer, the Alert viewer.
//
var alert:AbstractClass = new AlertView(model,controller);
addChild (alert);
/*
* Eventlisteners. These events are triggered by the Model and cause the viewers
* to react.
*/
model.addEventListener ("viewWindow", view.update);
model.addEventListener ("serverError", view.update);
model.addEventListener ("serverResponse", view.update);
model.addEventListener ("alertWindow", alert.update);
}
}
}