Jump to content


Extending ContentDisplay

Recommended Posts

Several time in my application I need to use an ImageLoader but do lot of things on the contentdisplay.


I therefore made classes that extend ContentDisplay and add the ImageLoader in the constructor.


It seems ImageLoader creates its own contentdislpay and forget about mine.


When I use the setContentDisplay function it almost works. Images are added but not with the correct fitWidth or fitHeight I set.


Could you add a variable that allow setting the contentdisplay?



Link to comment
Share on other sites

It sounds like you must be extending ContentDisplay incorrectly. Help me understand why you're even doing that in the first place.


It's important that ImageLoaders, SWFLoaders, and VIdeoLoaders create a ContentDisplay right away in their constructor for several reasons (I'll spare you the boring explanation) and I don't think it would be appropriate to allow you to change the Loader's ContentDisplay. Maybe I just need help understanding your objectives so I can offer a better solution.

Link to comment
Share on other sites

Well, most of times im interested in manipulating images. Those images are Loaded with an ImageLoader. It is convenient for me to create a class that has all the functionalities I want with this image.


If I am using a loader. I have to add the content of the loader to my class:


loader = new ImageLoader("path to the image.jpg",vars);
var image:Image = new Image()


This makes me having a sprite sitting on another sprite on which sits rawContent.


I'd rather have the ContentDisplay available right away and with which I can use my own method if needed.

Link to comment
Share on other sites

You're welcome to do that, but I personally think it's much cleaner to have the extra Sprite (that's really not a big deal in terms of memory) and avoid tinkering with LoaderMax and its relationship with ContentDisplay. I didn't design ContentDisplay to be anything other than a container for the rawContent that performs a few key functions like resizing. The intention wasn't to have developers add a bunch of their own content in there, manage things, extend it, swap ContentDisplay objects for others in a loader, etc. In fact, I think it's very important to make sure that the ContentDisplay remain consistent for any given loader (not allow swapping). A lot of problems could arise otherwise (I'll spare you the boring explanation). But feel free to extend it if you prefer.

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.