Hi chkdesign,
this is what i came up with.
not exactly random but decided to set certain colors and weight them
just like the SwitchInitializer class.
package {
import flash.display.DisplayObject;
import flash.geom.ColorTransform;
import idv.cjcat.stardust.common.particles.Particle;
import idv.cjcat.stardust.common.utils.WeightedCollection;
import idv.cjcat.stardust.common.xml.XMLBuilder;
public class Colors extends Initializer {
private var _collection:WeightedCollection;
/**
*
* @param colors
* @param weights
*/
public function Colors(colors:Array = null, weights:Array = null) {
if (!colors) colors = [];
if (!weights) {
var len:int = colors.length;
var weights:Array = [];
for (var i:int = 0; i < len; i++) weights[i] = 1;
}
setColors(colors, weights);
}
public function setColors(colors:Array = null, weights:Array =
null):void
{
_collection = new WeightedCollection(colors, weights);
}
/**
*
* @param particle
*/
override public function initialize(particle:Particle):void
{
var color:uint = _collection.get() as uint;
var ct:ColorTransform = new ColorTransform();
ct.color = color;
(particle.target as DisplayObject).transform.colorTransform = ct;
}
//XML
//------------------------------------------------------------------------------------------------
...
//------------------------------------------------------------------------------------------------
//end of XML
}
}
usage would be...
addInitializer(new Colors([0xcce28f, 0x79a81c, 0xc9afd4, 0x75587b],
[1, 1, 1, 1]));
On Jun 2, 4:39 pm, "
chkdes...@googlemail.com"