public class ColorLibrary {
private var _allColorCodes:Object;
public function ColorLibrary() {
init();
}
private function init(){
_allColorCodes = {
'black' : '000000',
'white' : 'FFFFFF',
'yellow' : '000000'
}
}
public function exchangeColor(colors:String){
var colorArray:Array = colors.split(',');
for ( var i:int = 0; i < colorArray.length; i++ ) {
_allColorCodes.getDefinitionByName(colorArray[i]);
}
}
}
any idea how to convert string to instance name? Thanks very much~! Strugglying here
I can´t see why you would want to do it like this, but here is a function that passes a list of colors (String) and returns hex codes (Array). If one color does not exist you will get lost in the Array. I Recommend using
ColorList.REDor at leastColorManager.getColor("red").