Well it has been some time since my last blog post - nearly three and a half months and now finally I seem to have found a little free time to dedicate to some writing, I tell you dispite all of the fuss in the press lately with the Apple - Adobe thing and also Flash vs HTML5, it seems to me that it sure is a great time to be a flash developer as we seem to be so in demand!
Anyway, to ease my self back into my blog writing I am going to post a little class which I knocked up when working on a project recently as a nice transition effect for adding / removing images. It is simlilar to an experiment I posted on my very bare lab site some time ago. The class is called Broken image and it does just that. It is a simple class which takes any movieclip / sprite / bitmap passed as one of its parameters, the image passed can be added to the stage already or not it doesn't matter. Other parameters include, x & y positions that you wish the final image to sit on, width and height of each pixel and whether you wish the transitions to be 'in', 'out' or both. The below code, would add an asset called 'image' as the image to be broken apart, set it in the middle of the stage, with an in & out transition, and each 'pixel' as they are defined in the class would be 15 x 15 pixels.
-
var bi:BrokenImage = new BrokenImage(image, (stage.stageWidth - image.width) * 0.5, (stage.stageHeight - image.height) * 0.5, "inOut", 15, 15);
It then reacreates the image as a series of smaller bitmaps made up of the original which are then ready to be animated. As a basis of the class I have included a simple tweenIn and tweenOut, which of course can easily be adjusted to suit your needs.
As you will see if you explore the code, the actual inner workings of the class are very simple and pretty self explnatory. In the example document class which I have included with the source, I have used a loader to load in a bitmap, this is mainly to reduce overall file size so that it can easilt be loaded onto this blog page, but you can easily use any asset from flash by giving it a linkage ID or even just an instance name. Of course as the example included is 100% actionscript, if you do compile in flash you will to define a document class. The class also requires tweenlite as its tween engine so you will also need that defined in your library preferences.
Get the source files here.


![Validate my RSS feed [Valid RSS]](http://www.ultravisual.co.uk/blog/images/valid-rss.png)

