Be a Supporter!

Optimum way to load images from lib

  • 275 Views
  • 5 Replies
New Topic Respond to this Topic
rub0gameton
rub0gameton
  • Member since: Oct. 14, 2010
  • Offline.
Forum Stats
Member
Level 02
Game Developer
Optimum way to load images from lib Oct. 5th, 2012 @ 10:38 PM Reply

I have made a custom class. This class should load an image depending on the parameter that is send to it. I managed to make it work with an external image; however, how would I go for doing it with an image from the library

block.as

package 
{
	import flash.display.MovieClip;

	public class block extends flash.display.MovieClip
	{

		public function block(blockX:int, blockY:int, id:int, material:int)
		{
			this.x=blockX*32;
			this.y=blockY*32;

			// Load image depending upon parameter here.
		}

	}

}

And no, this is not MineCraft , believe it or not =P (not even close). I just somehow got to use the same terms as they are used there. And for some random reason my code is pretty much exactly the same as MineCraft's. But anyways, any help would be appreciated.


Working on a few projects. Learning my way through AS3.

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Optimum way to load images from lib Oct. 5th, 2012 @ 11:11 PM Reply

I would load an MC and have it go to a frame based on the parameter.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
rub0gameton
rub0gameton
  • Member since: Oct. 14, 2010
  • Offline.
Forum Stats
Member
Level 02
Game Developer
Response to Optimum way to load images from lib Oct. 6th, 2012 @ 07:04 AM Reply

At 10/5/12 11:11 PM, MintPaw wrote: I would load an MC and have it go to a frame based on the parameter.

I'll try that


Working on a few projects. Learning my way through AS3.

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Optimum way to load images from lib Oct. 6th, 2012 @ 10:15 AM Reply

Although on a side note if you're trying to use MovieClips as tiles your game is going to get really laggy really fast.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Optimum way to load images from lib Oct. 6th, 2012 @ 12:26 PM Reply

At 10/6/12 10:15 AM, MintPaw wrote: Although on a side note if you're trying to use MovieClips as tiles your game is going to get really laggy really fast.

You could use bitmapData.draw to convert the movieclip to raster graphics and have minimal lag if you draw everything at compile time. Plus copyPixels is really fast.

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Optimum way to load images from lib Oct. 6th, 2012 @ 02:37 PM Reply

Yeah, but is block class (which should be capitalized btw) is already extending MovieClip. It's set up for failure.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature