Jump to content
Search Community

Best way to pass a loaded bitmap to a class?

Nickbee test
Moderator Tag

Recommended Posts

I currently use a class to load and slice jpg images. I use arguments to pass the class a URL and the amount of slices horizontally and vertically. The class then loads the image and uses bitmapData to slice things up. So now that I'm using LoaderMax to preload stuff I would like to pass my class the info from a loaderMax object. What would be the best way to do this knowing that I eventually need to use bitmapData in my slice class?

 

Thanks and happy Thanksgiving!

Link to comment
Share on other sites

that pointed me in the right direction...

 

The constructor of my SliceBitmap class now looks like this...

 

public function SliceBitmap(imageData:BitmapData, numRows:uint, numCols:uint)
	{
		//set vars to arguments
		_imageData = imageData;
		_numRows = numRows;
		_numCols = numCols;
		init();
	}

 

in my main class I have my loadermax stuff like this:

 

		private function LoadImages():void
	{
	//<<---------------------- LOADER MAX ---------------------->>
	var myLoaderMax:LoaderMax = new LoaderMax({name:"myLoader", maxConnections:2});

	myLoaderMax.append(new ImageLoader("images/dart.jpg", {name:"dart"}));
	myLoaderMax.append(new ImageLoader("images/strawberry.jpg", {name:"strawberry"}}));
	myLoaderMax.append(new ImageLoader("images/bottle.jpg", {name:"bottle"}}));

	//start loading
	myLoaderMax.load();
	}

 

so lets say I want to pass my SliceBitmap class the bitmap data from "dart" how would I do this?

 

I am keeping things simple for this example, I'll eventually add complete listeners and priority stuff.

 

thanks!!!!

Link to comment
Share on other sites

I figured it out

 

var loader:ImageLoader = LoaderMax.getLoader("dart");
			var bitmap:Bitmap = loader.rawContent;

			SliceBitmap(bitmap, 3, 3);

 

I am passing a bitmap object to my SliceBitmap class and then it's taking care of the rest....

 

Thanks for pointing me in the right direction!!!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...