How to get up and running with Apparat

@joa recently posted a simple example to illustrate the power of his powerfull optimization framework called Apparat.

Apparat is a framework to optimize ABC, SWC and SWF files.

From the description of the Google Code page we get a hint of what Apparat actually does: “Apparat is a framework to optimize ABC, SWC and SWF files.”. In layman’s terms: “Apparat will speed up your Actionscript projects by optimizing certain method calls.”. The Actionscript Library for example provides some ( much ) faster ways of doing math and bitwise operations. Read on to understand more about how to get up and running with Apparat.
Continue reading How to get up and running with Apparat

Smoothing <mx:image/> – the simple way

Solved this little problem the simple way. One of the centralized file sharing applications we’re developing needed some form of branding at the bottom of the screens. The logo bar, 1400 px wide, needs to be resized when the user changes the resolution of the browserwindow.

Without smoothing, things turn ugly and pixelated. With smoothing turned on, everything keeps looking the way it should, even when resized.

<mx:VBox>
    <mx:script>
	private function smoothImage ( img : Image ) : void
	{
		var bmp : Bitmap = img.content as Bitmap;
		bmp.smoothing = true;
	}
    </mx:script>
    <mx:image id="logoImage" complete="smoothImage(logoImage)" source="images/logo.png" width="100%" scaleContent="true"/>
</mx:VBox>

How to merge two images into one using Actionscript

Well, it’s very easy, using BitmapData and Bitmap. This example makes things a bit more complex to show some principles. Hope you learn something out of it off course.

// we'll scale the first ( background ) image by 50%
var s : Number = .5;

// create a matrix to make the scalilng of the bitmap possible
var scaleMatrix : Matrix = new Matrix();

// apply the scaling to the matrix
scaleMatrix.scale(s,s);

// create a bitmapdata object from an existing bitmap ( "bmp" in this case )
var scaledBitmap : BitmapData = new BitmapData(bmp.width*s,bmp.height*s,false,0);

// draw the content and scale it using the matrix
scaledBitmap.draw(bmp,scaleMatrix);

// we have an embedded asset called "flickr", a flickr logo in gif format
var icon : Bitmap = new flickr() as Bitmap;

// let's place it in the bottom right corner
var ix : Number = scaledBitmap.width-icon.width;
var ij : Number = scaledBitmap.height-icon.height;

// create a matrix for the position of the icon
// note the use of the ix and ij variables in the parameters
var positionMatrix : Matrix = new Matrix(1,0,0,1,ix,ij);

// draw the icon bmp to the bitmapdata
scaledBitmap.draw( icon, positionMatrix );

// add the new, merged, bitmap to your displaylist
var bmp : Bitmap = new Bitmap( scaledBitmap );
addChild( bmp );

// that's it!

PS: as per user comments I’ve also uploaded an example to use in the Flash IDE ( *.fla file ) – the above example assumes you’re using Flash Builder or another editor

I do have to say I don’t understand why people try to merge two bitmaps in Flash using the IDE. You could just as easily create a MovieClip with the two bitmaps on top of each other. Or am I missing something? Tell me in the comments!

Download the example *.fla file here: http://www.webdevotion.be/blog/wp-content/mergy.fla.zip

Soocial: sync that contact

Soocial is the latest kid on the syncin’ contacts block. You can use it sync contacts across Mac, PC, phones, Gmail, … It seems to work ok for me across OS X and Vista – I synced Gmail, Outlook and Address Book.

One problem for some people are pictures. Contacts with pictures can’t be synced for the moment, but that doesn’t affect me.

People on Tweakers.net are a bit scared about the privacy issue; who gives you the right to store other people’s contact information online at a third party’s server? That’s a valid point.

The upside of Soocial is the cancel button. You can cancel the account any given time. This makes it perfectly possible to create a big backup of all your contacts using their tools and then cancel the account again. So, no privacy issue there, given they actually destroy all the data off course.

One counterattack could be to make their software open source or to make it possible for people to install the package on their own servers. But is using your own server safer? Sometimes it could be, but a lot of times it isn’t.

Before I pressed the cancel button I took this screenshot to show you the clear cancellation policy of Soocial.

Give it a whirl. Maybe you’ll like it. A lot.