Layout and Model

August 13th, 2007

This flash tutorial explains how to use and hopefully expand on my Actionscript 2.0 layout and model classes. These classes extend the MovieClipLoader class to load flash movieClips and images into your flash projects with finer control than loadMovie().

I use a class that i named layout and another that i named model in almost every new flash project. These class files are included in my “New Flash Project” package.

You can name them anything you want. The names Layout and Model just make it easier to understand which set of movieclips you are referencing. You can use one, or both. Layouts are loaded on the screen (on _root), and Models are loaded on layouts, or the screen. However you want to label them, it’s still essentially movies within movies within movies…

Why should you use my layout and model class? because you are too lazy to just write one yourself, and don’t want to spend the extra 5 minutes.

Download the “New Flash Project” template

download “newflashproject.tar.bz2” 12.7 KB
download “newflashproject.zip” 16.5 KB
visit “New Flash Project page”

View the “layout” class

view “layout.as” 3.48 KB

View the “model” class

view “model.as” 2.45 KB

How To Use Layout actionscript 2.0

a reference to this layout’s movieClip myLayout.loadedLayout_mc to add actions to the Listener Object attached to this layout, use myLayout = new layout("myLayout"); myLayout.mcListener.onLoadInit = function(layout_mc:MovieClip){ //do stuff to myLayout.loadedLayout_mc after it’s loaded layout_mc._width = 300; layout_mc._height = 250; } myLayout.loadLayout(); to destroy the layout, use unloadLayout() myLayout.unloadLayout(); unloadLayout() will also send all models loaded on it to davey jones’ locker

How To Use Model actionscript 2.0

a reference to this model’s movieClip myModel.loadedModel_mc to add actions to the Listener Object attached to this model, use myModel = new model("myModel", myLayout); 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; } myModel.X = 200; myModel.Y = 300; myModel.loadModel(); to destroy the model, use unloadModel() myModel.unloadModel();

main.as Example actionscript 2.0

class main { private var ml:layout; private var mm1:model; private var mm2:model; private var mm3:model; function main() { this.ml = new layout("myLayout"); var thisMain:Object = this; this.ml.mcListener.onLoadInit = function(layout_mc:MovieClip){ //create and load myModel1 thisMain.mm1 = new model("myModel", layout_mc, true); //create myModel2 and give it some properties and load it thisMain.mm2 = new model("myModel", layout_mc); thisMain.mm2.X = 200; thisMain.mm2.Y = 350; thisMain.mm2.loadModel(); //create myModel3 and give it some actions to run after it is loaded thisMain.mm3 = new model("myModel", layout_mc); thisMain.mm3.mcListener.onLoadInit = function(thisModel_mc:MovieClip){ thisModel_mc._x = 250; thisModel_mc._y = 350; thisModel_mc._width = 350; thisModel_mc._height = 300; thisModel_mc._alpha = 40; } thisMain.mm3.loadModel(); } this.ml.loadLayout(); } }

i hope you see how powerful extending actionscript classes are and click on the ads to the right j/k

2 Responses to “Layout and Model”

Say Anything