In a Flash (Actionscript 3.0) project I'm working on, I'm trying to load a PNG file from the library, however which icon should load is not established until run-time.
The project is a weather bar that loads an icon associated to the data feed that's returned as a JSON object. I have tried the following:
var iconData:Class = getDefinitionByName("i"+image);
var i:* = new iconData(130, 130);
var bitmap:Bitmap = new Bitmap(i);
if(p==0){
today_mc.today_icon.addChild(bitmap);
}
There is a bunch of evaluation that happens to determine "image".
All of the imported files are included as Classes for use in Actionscript, as seen here:
The error I'm getting is:
Implicit coercion of a value with static type Object to a possibly unrelated type Class.
So if the JSON response says the weather code is '33', and I determine in the script that code 33 = icon 4 (i4), I need to load i4.png to the stage.