Archive for the ‘ Contribution ’ Category

Random number without repeat as3

We're using the random object for many things, by its nature it may repeat a number, but sometimes we don't want to get the same number more than once, for example when showing a random image out of an array of images, or jumping to a random frame in a MovieClip. Currently there is no 'unique' function in Actionscript, you have to write your own solution.

Here is my class for generating random numbers:

randomPlus



Download: RandomPlus.as.

Usage:
Create an instance of RandomPlus, defining the numbers scope (start & end numbers), including negative values. in case only one parameter is passed the RandomPlus object will assume it is the end number and that the start number is zero:
var rp:RandomPlus = new RandomPlus( end:Number, start:Number = 0 );

After that you can use 'getNum' public function that will return a random number within the scope:
rp.getNum(); // returns a Number

You can use public var 'len' to retrieve the length of the scope in case you want to use it for your function:
rp.len; // returns a Number

*The object will return unlimited amount of numbers, each time the entire scope was returned it will reshuffle the items so it will continue to return random numbers within the scope, in an ever-changing order.

Let me know if you liked it (or if you have suggestions), enjoy :)

Pure code AS3 spinning loading animation

While working on the video player, I wanted to show spinning loading animation while buffering, and since I decided that the whole thing will be pure code, with no library assets, I had to code this animation – just the kind of things I like.
It didn’t take long, and I decided to share it – why not?

So here it is:

loader animation with action script 3 code

What you need to do in order to use it is add two functions:


import LoadAnim;
...
private var myAnim :LoadAnim;
...

public function showAnim():void
{
myAnim = new LoadAnim(0x333333); // animation color
myAnim.x = stage.stageWidth / 2;
myAnim.y = stage.stageHeight / 2;
addChild(myAnim);
}

public function hideAnim():void
{
myAnim.stopAnim();
removeChildAt(1);
}

Download the class here, enjoy : )

Flash – Highlighting a string in a textfield

Jack Doyle at greensock shared a really cool AS2 class he calls ‘TextMetrics’ – sounds promising ha?The class calculates x/y coordinates of a string in a textfield, allowing highlighting it or calculating rows width.. nice.Check out his example. Thanks Jack!

OpenOffice for Mac – great news!

According to Philipp Lohmann, Sun Microsystems joins porting effort for OpenOffice.org for Mac. I’ve been using NeoOffice for a while now, and even though it got better (it should with the amount of patches they release), it is still kinda slow. But the current OpenOffice Mac port uses X11, and performs even worse, it been years this way.
Better late than never.

Cyberduck your files – ftp for mac

cyberduck2.jpg
I was using all kind of FTP clients along the years, mainlly on PC’s, and my Mac was always neglected because there was no decent client to work with. when I found this great free application – Cyberduck – I was surprized how well it works and how intuitive the interface is.
I contacted David the auther and joined him to translate cyberduck to Hebrew.
If you use FTP on a Mac – it’s a must-have application, Cyberduck 2.7.2 is to be released within the next two days,

 

Bad Behavior has blocked 14 access attempts in the last 7 days.