ImageLoader class for Flash 8
Thursday 17 August 2006 – Filed under: Flash – 9 Comments
This piece of code has been lying around for some time. I wrote it due to the fact that Flash 8 doesn’t smooth dynamically loaded images by default. This means that scaling and rotating any dynamically loaded image will make it look “jagged”.
The first (for as far as I know) to write Flash code to circumvent this issue was Master Tinic Uro himself; he is one of the engineers at Adobe working on the Flash Player. He wrote a handy function to load an image dynamically and then smooth it using a neat BitmapData / MovieClip trick
I wrapped his idea and some extras (events from MovieClipLoader class are relayed and the PNG transpareny solution is also included) in a single class I dubbed ImageLoader (duh).
Usage is as follows:
var loader:ImageLoader = new ImageLoader(); loader.addListener(this); loader.loadImage( "some_image.jpg", some_mc );
In the sample above, the ‘this’ context will receive all events normally fired by the MovieClipLoader class while loading an image.

« previously: We won gold, again! next: Screenweaver HX released »
9 Responses
Leave a Reply
Recent Articles
- AS3 Tweetr library suffers from the Twitpocalypse bug
- Digital TV on Mac Mini, part 2
- Digital TV on Mac Mini, part 1
- New bike
- FLV Player 2.0.25 released
- No custom headers for Flash file upload. Why?
- Building AIR with FDT
- Adobe MAX 2007
Advertisement
Categories
- Art & Design (4)
- Flash (38)
- FLV Player (9)
- Software (16)
- User Experience Design (3)
- Various (10)
- Work (6)
Wednesday 22 August 2007 at 21:15
Many thanks for sharing your work and effort.
I also don’t like open flash to view flv files.
Thanks and good job for you.
Sunday 2 September 2007 at 12:22
Thanks a lot for that piece of code. I’ve been searching some of this for two weeks ago. I also found some script for solve this problem (using class BitmapData), you can read about it in my blog (in spanish…).
[http://www.evostudio.com/litus-host/litus-blog/lb_02/post.php?view_p_id=47]
Bye!
Wednesday 31 October 2007 at 04:41
Very useful piece of code, thanks for that.
Only unfortunate issue is that it seems to slow Flash down a lot. Is this built into newer (9+) versions of the player, I remember Tinic mentioning a more native smoothing function?
Tuesday 13 May 2008 at 20:38
Ran into a couple problems using this script as we needed to load images across domains in a flash banner ad.
1) The mLoader instance within the class has no parent MovieClip, and triggers sandbox violations when loading images across domains. Replacing the constructor function remedies the problem:
public function ImageLoader ( targetMc:MovieClip ) {
targetMc.mcLoader = new MovieClipLoader();
mLoader = targetMc.mcLoader;
addListener(this);
}
2) This requires a change in the instantiation code, as the parent(ing) movieClip needs to be passed as an argument:
1. var loader:ImageLoader = new ImageLoader(this);
2. loader.loadImage( “some_image.jpg”, some_mc );
3) We removed this line in the instantiation script:
loader.addListener(this);
The listener is added immediately within the class in the constructor function, so this seems redundant?
Hope this can be used by others needing Flash 8 dynamic bitmap smoothing, and thanks Martijn!
Thursday 5 June 2008 at 12:51
I’m having some problems with the class. I´m loading the class into a another one:
import com.planche.ImageLoader;
and then on a function:
public function setImage(l:String):Void
{
var loader:ImageLoader = new ImageLoader(this);
loader.loadImage(l, img_mc); // where l is a string coming from loaded xml
}
I’ve made some tracing and the l string is ok, but the image doesn’t load… any help or any problem found..
Thursday 5 June 2008 at 13:59
problem solved
public function setImage(l:String):Void
{
var loader:ImageLoader = new ImageLoader(this);
loader.loadImage(l.toString(), img_mc); // where l is a string coming from loaded xml
}
Monday 8 December 2008 at 16:42
excellent class. This really is a very handy bit of code. Thanks.
Wednesday 24 December 2008 at 00:13
Wonderful, wonderful class. It made a world of a difference and was ridiculously easy to implement. Bravo!
Monday 25 May 2009 at 13:57
how if i want to load more than one image, and in my case i want to add my own listener.,could i?
Thanks