Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 17th, 2003, 06:28 AM
andywhitt's Avatar
andywhitt andywhitt is offline
PHP Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: England
Posts: 163 andywhitt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 55 m 11 sec
Reputation Power: 11
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

Reply With Quote
  #2  
Old February 17th, 2003, 12:34 PM
bret bret is offline
flash junkie
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: CO, USA
Posts: 172 bret User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 38 sec
Reputation Power: 11
Send a message via Yahoo to bret
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:
//actionscript:
this.createEmptyMovieClip ("line_mc"1);
x_pos = [150120150400];
y_pos = [360150170450];
with (line_mc) {
    
lineStyle (10x000000100);
    for (
i=0i<x_pos.lengthi++) {
        
lineTo (x_pos[i], y_pos[i]);
    }


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

Reply With Quote
  #3  
Old February 17th, 2003, 03:23 PM
andywhitt's Avatar
andywhitt andywhitt is offline
PHP Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: England
Posts: 163 andywhitt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 55 m 11 sec
Reputation Power: 11
Thanks dude!!

Will look at it tomoz at work.


Reply With Quote
  #4  
Old February 20th, 2003, 10:41 AM
andywhitt's Avatar
andywhitt andywhitt is offline
PHP Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: England
Posts: 163 andywhitt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 55 m 11 sec
Reputation Power: 11
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


Reply With Quote
  #5  
Old February 20th, 2003, 11:24 AM
bret bret is offline
flash junkie
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: CO, USA
Posts: 172 bret User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 38 sec
Reputation Power: 11
Send a message via Yahoo to bret
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:
//actionscript
this.createEmptyMovieClip("curve_mc",1);
curve_mc.lineStyle(1,0x000000,100);
curve_mc.curveTo(100,0,100,100); 


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

Reply With Quote
  #6  
Old February 21st, 2003, 06:23 AM
andywhitt's Avatar
andywhitt andywhitt is offline
PHP Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: England
Posts: 163 andywhitt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 55 m 11 sec
Reputation Power: 11
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:
 this.createEmptyMovieClip ("curve_mc"1);
skewY 400;
x_pos = [50100150200250300];
y_pos = [35060150170450,0];

with (curve_mc
{
    
lineStyle (10x000000100);
    for (
i=0i<x_pos.lengthi++) 
    {
        
curve_mc.lineTo(x_pos[i],skewY-y_pos[i]);
    }




curvy version :

PHP Code:
 this.createEmptyMovieClip ("curve_mc"1);
skewY 400;
x_pos = [50100150200250300];
y_pos = [35060150170450,0];

with (curve_mc
{
    
lineStyle (10x000000100);
    for (
i=0i<x_pos.lengthi++) 
    {
        
curve_mc.curveTo(100,0,x_pos[i],skewY-y_pos[i]);
    }



Thanks

Reply With Quote
  #7  
Old February 21st, 2003, 11:13 AM
bret bret is offline
flash junkie
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: CO, USA
Posts: 172 bret User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 38 sec
Reputation Power: 11
Send a message via Yahoo to bret
hey,

here's what i mean.. create two more arrays that house the x and y control:

PHP Code:
 this.createEmptyMovieClip ("curve_mc"1);
x_control = [25100125175225300];
y_control = [375,200,90,180,425,425];
x_pos = [50100150200250300];
y_pos = [35060150170450,0];

with (curve_mc
{
    
lineStyle (10x000000100);
    for (
i=0i<x_pos.lengthi++) 
    {
        
curveTo(x_control[i],y_control[i],x_pos[i],y_pos[i]);
    }



mess with that and see if you can't get what you are looking for..

cheers,

bret

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Flash cordinates and pixels

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap