/* Quickly load movie clips from the models directory onto a layout Models will be loaded at _x = 0 _y = 0 of the layout (or _root if no layout is specified) Examples found at http://remixtechnology.com/view/layout-and-model public properties - modelName_str :String - name of the model object - X :Number - get or set _x property of movieClip that is referenced by this model object - Y :Number - get or set _y property of movieClip that is referenced by this model object - loadedModel_mc :MovieClip - the movieClip that is referenced by this model object - loadedLayout_mc :MovieClip - movieClip object that this model is loaded into - mcListener :Object public methods - loadModel() :Void - loads this model - unloadModel() :Void - unloads this model - constructor model([Filename of movieclip to load, without extension]:String, [layout object to load model into]:layout, [load model now?]:Boolean) ex: (in main.as) class main{ private var _myLayout:layout; private var _myModel:model; function main(){ this._myLayout = new layout("myLayout", true); this._myModel = new model("myModel", this._myLayout, true); } } to reference this model use this._myModel.loadedModel_mc to add actions to the Listener Object attached to this model, use this._myModel = new model("myModel", this._myLayout); this._myModel.mcListener.onLoadInit = function(thisModel_mc:MovieClip){ //do stuff to _myModel.loadedModel_mc after it's loaded thisModel_mc._width = 300; thisModel_mc._height = 250; } this._myModel.X = 200; this._myModel.Y = 300; this._myModel.loadModel(); to destroy the model, use unloadModel() this._myModel.unloadModel(); */ class model extends MovieClipLoader{ private var _modelName:String; private var _X:Number; private var _Y:Number; private var _loadedModel_mc:MovieClip; private var _layout_mc:MovieClip; private var _mclistener:Object; public function get modelName_str():String{ return this._modelName; } public function set X(X:Number):Void{ this._X = X; } public function get X():Number{ return this._X; } public function set Y(Y:Number):Void{ this._Y = Y; } public function get Y():Number{ return this._Y; } public function get loadedModel_mc():MovieClip{ return this._loadedModel_mc; } public function get loadedLayout_mc():MovieClip{ return this._layout_mc; } public function get mcListener():Object{ return this._mclistener; } public function loadModel():Void { if (!this._X) this._X = 0; if (!this._Y) this._Y = 0; if (this._layout_mc == undefined) this._layout_mc = _root; trace("loading " + this._modelName + " into " + this._layout_mc); this._loadedModel_mc = this._layout_mc.createEmptyMovieClip(this._modelName + this._layout_mc.getNextHighestDepth(), this._layout_mc.getNextHighestDepth()); this._loadedModel_mc._x = this._X; this._loadedModel_mc._y = this._Y; this.loadClip(cfg.modelsDir + this._modelName + cfg.modelsExt, this._loadedModel_mc); } public function unloadModel():Void { unloadMovie(this._layout_mc[this._modelName]); this._layout_mc[this._modelName].removeMovieClip(); } public function model(modelName_str:String, loaded_layout_mc:MovieClip, loadNow:Boolean ){ super(); this._modelName = modelName_str; this._layout_mc = loaded_layout_mc; this._mclistener = new Object(); this.addListener(this._mclistener); if(loadNow) this.loadModel(); } }