Loading external images

By Lenster921 | Jul 10, 2009

actionscript3

I’m trying to simply reskin an existing Tower Defense game tutorial. As of now, the sprites are being drawn directly from code. I wouldn’t like to switch the display graphics from the fill function to an actual ground sprite that I made myself. The code looks like:

ActionScript Code:
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:

actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

Loading external images

By Lenster921 | Jul 10, 2009

actionscript3

I’m trying to simply reskin an existing Tower Defense game tutorial. As of now, the sprites are being drawn directly from code. I wouldn’t like to switch the display graphics from the fill function to an actual ground sprite that I made myself. The code looks like:

ActionScript Code:
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:

actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0