Graphing a mathematical equation in AS2

83 views Asked by At

I'm trying to write a simple AS2 script that graphs a second degree polynomial by plotting the first 100 points of the equation,i made a red dot,converted it to a symbol called point,created a new frame and inserted the following code:

var X:Number=0;
var Y:Number=0;
var a:Number=3;
var b:Number=3;
var c:Number=3;
var i:Number=0;

function func(X,Y,a,b,c){
Y=a*X*X+b*Y+c
}
while(X=O,X<100,++X,i=O,i<100,++i){
attachMovie("point", "pont+i", 0, {_x:X, _y:Y});
}


func(X,Y,a,b,c)

The idea is that this code would start creating instances of the red dot respectively named pont0,pont2,pont3,...,pont99 but it doesn't seem to be working as intended. The error log shows nothing,and neither does the .swf file,what am I doing wrong?

1

There are 1 answers

7
Aspiro On BEST ANSWER

Looks like your problem is in while usage.It has only one argument - condition statement

try something like this

  var X:Number=0;
  var Y:Number=0;
  var a:Number=3;
  var b:Number=3;
  var c:Number=3;
  var i:Number=0;

  function func(X,Y,a,b,c){
        return a*X*X+b*Y+c
  }

  while(i<100){
        attachMovie("pont", "pont+i", i, {_x:X, _y:func(X,Y,a,b,c)});
        i++;
        X++;
  }