Expand|Select|Wrap|Line Numbers
- var maxBox:Number = 300;
- var i:Number = 1;
- createNewBox();
- function createNewBox(){
- if(_root.i < maxBox){
- var container_mc:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
- container_mc.attachMovie("Box","Box1",this.getNextHighestDepth());
- var size = (random(100) + 20);
- var xrand = random(500);
- var yrand = random(500);
- container_mc._height = size;
- container_mc._width = size;
- container_mc._x = xrand;
- container_mc._y = yrand
- }
- }
Everything works as it is supposed to (a number of boxes are created and placed on the stage with different sizes and positions) Although my code works im sure it could be written better. My main thought is that Each box will have the same instance name "container_mc.Box1" Also there will be many container_mc made rather than 1 container_mc with many Boxes inside. I have tried moving the statement where i create the container outside of the loop but cannot get anything to appear. Much thanks to anyone would be kind enough to edit my code.
-Shawn