tags:

views:

1338

answers:

2

Hi guys, I really appreciate all help I can get on this problem that I have found.

I have created several resource modules with the MXMLC tool using properties files.

Files get generated correctly and I'm able to load them using the resourceManager.loadResourceModule( ) function.

Now here is the problem.

On those files I've embedded several images.

With the application I make some modifications to those images, as long as they are BitmapAssets.

The problem is that I get an error or a null reference if I try the following.

// With this one I get null.
var image:BitmapAsset = resourceManager.getClass( 'myResourceBundle', 'mainImage' ) as BitmapAsset;

// With this one an error.
var image2:BitmapAsset = BitmapAsset( resourceManager.getClass( 'myResourceBundle', 'mainImage' ) );

Is there a way I can make that cast and it works correctly?

Again, I really appreciate all help I can get.

Thanks.

+4  A: 

resourceManager.getClass returns a class, not an instance. Rewrite your code to something like this:

var imageResource : Class = resourceManager.getClass('myResourceBundle', 'mainImage');

var image : BitmapAsset = new imageResource();

That should do the trick, although you might need to do BitmapAsset(new imageResource()) if the compiler complains, can't remember right now how it is.

Theo
A: 

Thanks. It worked. :)