A Better Image Loader Class for AS3
I have been using this class for ages but I thought I’d share it with everyone. It does the following things that a conventional Loader class does not:
- Automatic scaling
- Bitmap smoothing (for custom scales)
- PNG transparency
- Graceful error control (black box for when the image fails to load)
Working with the Loader class on images can be tedious as it doesn’t really behave the way we expect it to, so I created this class to handle everything automatically.
The usage is simple:
var image:Image = new Image(0,0) // Use numbers for the x, y dimensions to force the image to a specific size or aspect ratio. 0,0 uses the default image size when loaded.
image.addEventListener(Event.INIT, _imageInitialized); // Make this callback whatever you'd like, although it's not necessary.
image.load("http://www.mysite.com/myimage.png");
You can download the source code to the class here:
Image Class
3 Comments
Hi.
Can I smooth images with this class?
Thanks.
Marlon the class automatically smooths it to the dimensions you provide in the parameters, so it’s already taken care of
Buy:Cialis Soft Tabs.Viagra.Viagra Soft Tabs.Cialis Professional.Propecia.Soma.Viagra Super Force.Tramadol.Cialis.Maxaman.Super Active ED Pack.Cialis Super Active+.Viagra Super Active+.Viagra Professional.Levitra.Zithromax.VPXL….