Ever used LoaderContext?

Kevin, another Flash/Flex developer on my team, has a good poston his blog on the LoaderContext class and using it for getting access to the BitmapData object of an image loaded off a domain other than the one hosts the swf. I never tried this with AS2, so when we were unable to get BitmapData off a domain that had the correct crossdomain policy file, he was convinced that it could not be done since apparently AS2 had no way to do this. AS3 introduces the concept of LoaderContext that checks the crossdomain.xml in such situations. The LoaderContext is an optional parameter to the Loader class’s load() function. Whats weird is by default, the Loader doesnt which is counter-intuitive, since all other such crossdomain look ups do.

I am excited about the presence of LoaderContext though since another thing it allows is loading classes to their own ApplicationDomain, which means the potential for class collisions is virtually eliminated. When would this be useful? Well, for one if you are loading swfs using the same third party libraries, but there is a potential that someone tweaked some part of it making it behave slightly different. In my world this is a very real issue. I am just bummed that the code that I have such issues with is still in AS2 with no such security mechanisms.

Anyway, check his post out. While he talks about the Image component, the same idea is valid for the AS3 Loader class.

Author: Arpit Mathur

Arpit Mathur is a Principal Engineer at Comcast Labs where he is currently working on a variety of topics including Machine Learning, Affective Computing, and Blockchain applications. Arpit has also worked extensively on Android and iOS applications, Virtual Reality apps as well as with web technologies like JavaScript, HTML and Ruby on Rails. He also spent a couple of years in the User Experience team as a Creative Technologist.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: