|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Flash cordinates and pixels
I am trying to create a dynamic line graph, i'm wanting to put a pixel on a scene,
I wanting to do, something like this: pseudeo code: for(i=0;lengthof(array);i++) { putpixel(array(i)(x), array(i)(y)) } i'm having trouble finding something to draw a pixel at x and y, from my 2 dimensional array; any sugestions would be cool. thanks |
|
#2
|
|||
|
|||
|
sure, you'll need to use the Drawing API (and of course, use Actionscript syntax, not PHP
Everything is done with movieclips, so we'll need to create a new one:this.createEmptyMovieClip("line_mc",1); then(or first) we want to create our position arrays x_pos = [1,50,120,150,400]; y_pos = [3,60,150,170,450]; we want to use the line_mc to draw lines (using the lineTo method): with(line_mc){ lineStyle(1,0x000000,100); for(i=0;i<x_pos.length;i++){ lineTo(x_pos[i],y_pos[i]); } } and that's it! here's a look at all of the code: PHP Code:
the lineStyle code takes three parameters -- line width, colour and alpha. the lineTo takes two parameters -- x and y. mess around with it. if you know PHP it shouldn't seem too foreign. cheers, bret |
|
#3
|
||||
|
||||
|
Thanks dude!!
Will look at it tomoz at work. ![]() |
|
#4
|
||||
|
||||
|
Cool thats what i was looking for, this nect question is a little harder, with the data been displayed not been mission critical or anything, is there anyway of curving the line.
Say i have data like you provided, whihc is a line going diaganolly down to the left, with a hump, is there anyway of slightly making it more curvy, without chnaging the values ? Thanks ![]() |
|
#5
|
|||
|
|||
|
sure, you can use the curveTo method. it takes 4 arguments: controlx, controly, anchorx and anchory. The curveTo function emulates a 1 point bezier curve. This means that your control points will determine the amount of curve. here's an example of a simple curve from 0 to 100 pixels:
PHP Code:
you'll have to create another two arrays to hold the controlx and the controly values, but the implementation would still be the same... write back if you're still having problems. cheers, bret |
|
#6
|
||||
|
||||
|
550x400 Canvas:
The straight version looks ok, the curvy version looks emmmm, well weird lol, is there any way of just making the straight version bit more curvier or is there something i've missed on the curving. Straight version: PHP Code:
curvy version :PHP Code:
Thanks |
|
#7
|
|||
|
|||
|
hey,
here's what i mean.. create two more arrays that house the x and y control: PHP Code:
mess with that and see if you can't get what you are looking for.. cheers, bret |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Flash cordinates and pixels |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|