
var roadHolder:Sprite = new Sprite();//create an object that will hold all parts of the road addChild(roadHolder);//add it to the stage function makeRoad():void{ var row:int = 0;//the current row we’re working on var block;//this will act as the block that we’re placing down for(var i:int=0;i<lvlArray.length;i++){//creating a loop that’ll go through the level array if(lvlArray[i] == 0){//if the current index is set to 0 block = new EmptyBlock();//create a gray empty block block.graphics.beginFill(0×333333); block.graphics.drawRect(0,0,25,25); block.graphics.endFill(); addChild(block); //and set the coordinates to be relative to the place in the array block.x= (i-row*22)*25; block.y = row*25; } else if(lvlArray[i] == 1){//if there is supposed to be a row //just add a box that will be a darker color and won’t have any actions block = new Shape(); block.graphics.beginFill(0×111111); block.graphics.drawRect(0,0,25,25); block.graphics.endFill(); block.x= (i-row*22)*25; block.y = row*25; roadHolder.addChild(block);//add it to the roadHolder } else if(lvlArray[i] is String){//if it’s a string, meaning a special block //then create a special block block = new DirectBlock(lvlArray[i],(i-row*22)*25,row*25); addChild(block); }
These are some things I’ve been wondering about in terms of doing this switch from the draw functions to loading existing images.
1. Do I create MovieClips and call to them from the library?
2. Can I call images directly from a folder holding that image?
Can someone with more flash knowledge show me how this can be done? If you need more information please reply. :confused:
If you would like to make a comment, please fill out the form below.
var roadHolder:Sprite = new Sprite();//create an object that will hold all parts of the road addChild(roadHolder);//add it to the stage function makeRoad():void{ var row:int = 0;//the current row we’re working on var block;//this will act as the block that we’re placing down for(var i:int=0;i<lvlArray.length;i++){//creating a loop that’ll go through the level array if(lvlArray[i] == 0){//if the current index is set to 0 block = new EmptyBlock();//create a gray empty block block.graphics.beginFill(0×333333); block.graphics.drawRect(0,0,25,25); block.graphics.endFill(); addChild(block); //and set the coordinates to be relative to the place in the array block.x= (i-row*22)*25; block.y = row*25; } else if(lvlArray[i] == 1){//if there is supposed to be a row //just add a box that will be a darker color and won’t have any actions block = new Shape(); block.graphics.beginFill(0×111111); block.graphics.drawRect(0,0,25,25); block.graphics.endFill(); block.x= (i-row*22)*25; block.y = row*25; roadHolder.addChild(block);//add it to the roadHolder } else if(lvlArray[i] is String){//if it’s a string, meaning a special block //then create a special block block = new DirectBlock(lvlArray[i],(i-row*22)*25,row*25); addChild(block); }
These are some things I’ve been wondering about in terms of doing this switch from the draw functions to loading existing images.
1. Do I create MovieClips and call to them from the library?
2. Can I call images directly from a folder holding that image?
Can someone with more flash knowledge show me how this can be done? If you need more information please reply. :confused:
If you would like to make a comment, please fill out the form below.
Recent Comments