Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : Plotting graphs


MrBrazil
3/20/2004 9:28:38 PM
I need to draw functions graphs in the stage

examples:
y = sin(x)
y = x*x + 2x + 5
....

Any help

thanks!


pazzoboy
3/21/2004 2:00:09 PM
Okay, do you want a solution that satisfies both of those equations together or
separately? I'm trying both, and it looks like this: I made a small circle
movieclip with instance name "dot", dragged it from the library to a spot
offstage. Then, on the main timeline I put this:
stop();
startX=10;
startY=10;
endX=40;
endY=40;
for(z=startX;z<=endX;z++){
for(w=startY;w<=endY;w++){
duplicateMovieClip("dot","dot"+z,z);
plotY = sin(z);
plotX = (z*z+5-w)/-2;
setProperty(eval("dot"+z),_x,Math.abs(plotX));
setProperty(eval("dot"+z),_y,Math.abs(plotY));
}
}

The above code results in a series of dots going left to right, with more
space in between them as you look to the right.
pazzoboy
3/21/2004 2:15:06 PM
I also tried this, but to no avail...
for(z=startX;z<=endX;z++){
for(w=startY;w<=endY;w++){
duplicateMovieClip("dot","dot"+z,z);
if(w==(z*z+5-w)/-2 && w==Math.sin(z)){plotY=w;}
setProperty(eval("dot"+z),_x,z);
setProperty(eval("dot"+z),_y,plotY);

This is tricky.
kglad
3/21/2004 4:34:55 PM
MrBrazil
3/27/2004 2:02:25 PM
separately, each movie has one function
these are for a science project in physichs and we need animations, for
gravity, simple oscilation, newton's law and others
"pazzoboy" <webforumsuser@macromedia.com> escreveu na mensagem
news:c3k759$kal$1@forums.macromedia.com...
[quoted text, click to view]

kglad
3/27/2004 6:40:10 PM
AddThis Social Bookmark Button