Archive for May, 2009

Randomizing an Array

Posted in Actionscript, Flash on May 25th, 2009 by Sandro Haag – 4 Comments

Hi!

Here is a simple example of how to sort the items of an Array and get a randomized Array:

function sortArray (original:Array) : Array
{
   var temp:Array = original;
   var sort:Array = [];

   while (temp.length > 0)
   {
      var r:int = Math.random() * temp.length;
      sort.push(temp[r]);
      temp.splice(r, 1);
   }

   return sort;
}

Now, just execute the method, passing as parameter the Array that you want to randomize.

var original:Array = [0, 1, 2, 3, 4];
var randomized:Array = sortArray(original);
trace(”result: ” + randomized); // result: 3, 1, 4, 0, 2

That’s it!

Zinc 3.0

Posted in Actionscript, Flash, Zinc on May 18th, 2009 by Sandro Haag – 1 Comment

Hey!

Yes, a long time has passed since the last post. So here I am.

I am using Zinc 3.0 for a project, and here is my report of it.
In a few words, I can say that it is good, but not better than Adobe AIR.
It is a little complicated in the beggining, cause doesn`t have documentation. The only doc available is here, and it doesn’t  help so much.

To give an example, If I don’t do this:
mdm.Application.init(MovieClip(this), onInit);
The functions that I will execute will not work, but it will not throw me any error.
I have spent a considerable time to discover that I need to initiliaze the mdm classes.

When you have all configured, and familiared with the Zinc, it is kind’a easy to use. A lot of things you do in the Zinc Builder, on graphic mode. I guess the main problem of Zinc is the documentation, cause I think you can do everything with it, you just have to know how. Another problem is that there are not a lot of users, so this turns the thing a little bit complicated when you need some help.

Well, if someone has some question about it, just post here.

Thanks!