im trying to make a graphing calculator with drawing API.
I can’t get it so actionscript draws my line from the function that is produced from user input.
say i have an array
coefficients = [1,3,2,5];
where i is the coefficient of x^1 3 is the coefficient of x^2 and so on.
i have a function that converts that array to a function like
(1*(i^1))+(3*(i^2))+(2*(i^3))+(5*(i^4))
and i want to graph this string in a for loop like so
function update(coeffs:Array) {
func = "";
len = coeffs.length;
for (var i = 0; i<len; i++) {
func += "("+coeffs*+"*(i^"+Number(i+1)+"))";
i != len-1 ? func += "+" : func += "";
_root.holder.clear();
_root.holder.moveTo(0, 0);
_root.holder.lineStyle(1, 0x000000, 100);
_root.holder.lineTo(i*10,func);
//this is where i have trouble, it isn't picking up the "i" in the function string so it isn't graphing is what i think
}
trace(func);
// if the array is [1,3,2,5] this traces (1*(i^1))+(3*(i^2))+(2*(i^3))+(5*(i^4))
}
any help would be greatly appreciated
here is my fla if needed