Posts tagged ‘random’

AS3: Random Colour between 2 colour values

Leave a commentJuly 22 | 2009

Useful little snippet to generate a colour between 2 colour values in ActionScript 3

1
2
3
4
5
6
7
8
9
10
11
12
13
import fl.motion.Color;

var color1:uint = 0x03e338;
var color2:uint = 0xbbe303;
var newColor:uint = Color.interpolateColor(color1, color2, randomHue);

private function _randomNumber(low:Number=NaN, high:Number=NaN):Number
{
    var low:Number = low;
    var high:Number = high;

    return Math.random() * (high - low) + low;
}

Simple way to randomise Arrays in AS3

Leave a commentApril 21 | 2009

Found this over at daveoncode and thought i would like to share it:

1
2
3
4
5
6
7
8
9
10
private function _getRandom(arr:Array):void

    var arr2:Array = new Array();

    while (arr.length > 0) {
        arr2.push(arr.splice(Math.round(Math.random() * (arr.length - 1)), 1)[0]);
    }

    return arr2;
}

RUN DC AND JAM MASTER J

Leave a commentJanuary 21 | 2009

rundc

Just ordered my “RUN DC” from http://rundc08.com/SHOP.html . It will take a week or two, but who cares, that shirt is awesome.