Using the custom SimpleGraph class from flashandmath.com

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.

Back to Basic Tutorials              Back to Flash and Math Home

We welcome your comments, suggestions, and contributions. To contact us, email Barbara Kaskosz at barbara@flashandmath.com, Doug Ensley at doug@flashandmath.com, or Dan Gries at dan@flashandmath.com.

Adobe®, Flash®, Flex® are registered trademarks of Adobe Systems Incorporated.