Within the last year I switched my focus on native Java programming for Android. Surprisingly most of my programming skills from ActionScript 3 programming was quite useful and could be applied to this new area. Except I had to fight with framentation, one of the reasons I preferred Flash over HTML+CSS back in the days. Anyways, my first game that came out at the beginning of this year was a simple match-three bubble shooter: Koala Bubble Shooter
It has 44.000 downloads and is still going strong. I just added advertising to it, because the in-game-purchases were not really what I expected. I guess I won’t retire anytime soon. But is a really nice learning experience. Keep coming back to hear about my next games.
Creating greyscale images with ActionScripts ColorMatrixFilter is easy to do. If you want to preview the settings you can use the following tool.
You can also load any external image into it and play with the Matrix settings.
The code is automatically saved to your clipboard when you click on the output textField. You can simply paste it into your own project and add the filter to your own DisplayObject like this:
myObject.filters = [colorMatrixFilter];
Because I could not find a screen ruler that did exactly what I wanted (and for fun of playing with Adobe Air) I wrote my own. And of course I felt like sharing it with the community, so here is the download:
I built in some options that I felt were quite useful:
- option to set the background alpha: so now you can place the ruler on top of your screen or next to the object to be measured, just the way you like
- option to set the background color: in combination with the alpha you can always make your ruler appear in contrast to the measured object without distracting too much
- resising by dragging the corners: you can easily resize the ruler simply by dragging any corner in the desired direction
- hide to dock: hide the ruler to the docking station by choosing “hide” from the menu or simply clicking ESC on your keyboard
- move/resize single pixels: you can move the ruler with the arrow keys on your keyboard, and resize it with the arrow keys while holding down STRG (or the equivalent for your system)
But as we all know, a picture says a lot more than a few words, and a few pictures… well you get what i mean, so here are some screenshots of the tool:
This is reply to Apples change of rules for iPhone developers:
To be honest, I never really liked Apple products. I always liked the design, but not the restrictions and the disciples.
When the company I worked for gave all employees an iphone I was very sceptical. But it turned out that I got very used to this gadget that really does feel very nice. Apart from the fact that it was the end of me listening to music outside, because iTunes tried to take all life out of my PC, I enjoyed playing around with it and surfing the web.
Also the concept of the Appstore seemed amazing to me. An opportunity to sell small programs to a worldwide group of iPhone-users with not too many restrictions sounded better the more I thought about it.
Despite being a flash-developer, I considered looking into Objective-C, but simply up to now did not have the time to do so. Obviously it was great news for me when Adobe announced the iPhone-compiler for the upcoming Flash CS5 last year. Ever since that news I had been looking forward to this release…
As you well know, three days before the release you changed the rules, making all the work Adobe put into this feature pretty much worthless. To many this felt like a slap in the face of Adobe. Sitting aside, watching someone else work and getting their hopes up, just to crush all hope in the very last stage. This reminds me of a big slow kid in the playground that destroys the sand-castles of the other kids when they’re almost done.
But this is not only a slap in the face of Adobe, it is a slap in the face of all flash developers. So this is my reply to your actions: F*** you Mr. Jobs! Or in the words of Lee Brimelow: “Go screw yourself Apple”
Using Flash player 10 lets us use the rotationZ paramter of a TextField. But of course some clients require us actionscript developers to support the older player version as well.
An easy way to get around this problem is to draw the TextField into a Bitmap. I use my own TextUtils class with a static method like this:
public static function convertTextFieldToBitmap(textField : TextField) : Bitmap
var bitmapData : BitmapData = new BitmapData(textField.width, textField.height, true, 0×00000000);
var bitmap : Bitmap = new Bitmap(bitmapData);
bitmap.smoothing = true;
So rotating and fading the TextField is no problem anymore, also the scaling works much smoother:
- I embedded the swf in the HTML file in a <div> container with the style attribute “overflow:hidden;” and an id called “swf_container”.
- To ensure the desired effect I added stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT;
Of course you can try it out first:
Click the arrow in the top left corner to toggle sizes of the sample.
With this application you can train or simply test your mental rotation skills. One of the few skills that supposedly show a real difference between men and women as well as between students of natural sciences and students of the arts. But the ability to improve, especially a poor skill, has been shown.
So try it out, after 10 exercises you will see your results.
This application demonstrates the effect of pressure changes when diving:
This little Flash application implements four heuristics to solve the Travelling Salesman Problem:
How to use this application:
Type in the number of nodes and press build to set them up randomly (now max. 300 nodes).
Then you can test the different heuristics by clicking on the buttons in the top area. To hide a solution you can click the button again.
To set the nodes up differently, press build again.
NEW functionalities: Now you can edit the nodes and add new ones. Snap to grid and let the application show each step of the process.
Please comment if you are interested in some additional functionalities.
Download the AS3 Class now here. It is licensed under the Creative Commons Attribution 3.0 License. This allows you to use this class in personal and commercial products but you need to leave my name and link in the class, which is actually not seen by anyone after you publish the file. It would be nice to receive an html link, but it is not required.
To use this class do the following:
Unzip the class into the your class root folder (usually you can use the folder your .FLA file resides in). In your FLA import the class, create an object of the TSP class with an adjacency matrix. Call one of the four heuristics to receive a route array. Add the withHistory flag as true to receive the unfinished routes as well.
- import bjornson.Algos.TSP;
- var myTSP:TSP = new TSP(matrix);
- var nextNeighbour:Array = myTSP.returnNextNeighbour();
- var nearestInsertion:Array = myTSP.returnNearestInsertion();
- var farthestInsertion:Array = myTSP.returnFarthestInsertion();
- var cheapestInsertion:Array = myTSP.returnCheapestInsertion();
Now you can use the found path in any way you like. For example simply trace one:
trace(“Route found by cheapest insertion heuristic: “+cheapestInsertion.toString());
An adjacency matrix is simply a two-dimensional array containing the distances from each node to every other node. For example a small matrix containing only three nodes can look like this:
var matrix:Array = new Array( new Array( 0 , 1 , 2 ), new Array( 1, 0 , 3 ), new Array( 2 , 3 , 0 ));
At the moment only symmetric matrices can be used.
It has been a while that I first programmed a magnifier glass in Actionscrtip 2. But since several friends asked over time how to do it I rewrote it in AS 3.
You can download the entire class for free here: magnify.as
There are no license attachments whatsoever. So you can modify it, reuse it, sell it, whatever you like. But of course I would like to receive some feedback. You can also place links in the comments here to your site if you used this class.
The main important part is the following calculation:
First the image is loaded twice and then it positions the image that is only partially visible in the right spot over the smaller image so that it seems to be the same image.
To include the class in your own project all you need to is:
- unzip bjornson.zip into the same directory your FLA-file is in
- write code similar to this in your actions dialogue of your FLA (this is the very minimum you need):
- import bjornson.Magnify.Magnify;
var m:Magnify = new Magnify(“a.jpg”); //this should be a relative path to a .jpg or .png
- Publish the file, done!
- scr:String – this is the relative path to your image
- w:Number – this is the maximum width of the preview image
- h:Number – this is the maximum height of the preview image (it will be adjusted automatically to fit while keeping the correct aspect ratio)
- s:Boolean – this is to switch from a rectangular magnifier to a round magnifier
- r:Number – this is the radius of a round magnifier or the height of a rectangular magnifier
- rw:Number – this is the width of a rectangular magnifier
- m:Boolean – this defines if the Mouse-Pointer is visible when it moves over the image or not