This page will include our 30 lines of code with some commentary about the general methods. Page 3 of this tutorial includes documentation of more properties and methods of the SimpleGraph and GraphingBoard classes.
The code
import flashandmath.as3.tools.SimpleGraph;
txtXmin.tabIndex = 1;
txtXmax.tabIndex = 2;
txtYmin.tabIndex = 3;
txtYmax.tabIndex = 4;
txtFun.tabIndex = 5;
var g:SimpleGraph = new SimpleGraph(400,300);
g.x = 10;
g.y = 30;
addChild(g);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(kevt:KeyboardEvent):void {
if (kevt.keyCode == Keyboard.ENTER) {
drawGraph();
}
}
function drawGraph():void {
g.setWindow(txtXmin.text, txtXmax.text, txtYmin.text, txtYmax.text);
g.board.drawAxes();
g.board.drawTicks();
g.board.drawGrid();
g.board.addLabels();
g.graphRectangular(txtFun.text,"x",1,2,0x0000CC);
}
drawGraph();
Download
Download both fla files for this tutorial, along with the folder of class files and their documentation, in the following compressed folder.













