Sphere made up of 1000 lines?

I’m currently working on a project for my Interaction Design class. I’ve decided to do the entire interaction design in flash but I’m really bad at actionscrip. What I want is a bunch of straight lines that are the same length to stem from a single point outwards. I want them to be equi-distant forming a sphere much like a dandylion.

Can anyone point me in the right direction?

Cheers,
Michael

1000 lines… That seems like it would be really bad on the processor, especially if you had other things going on.

How about we just start with 100?

I’d look into using a loop and the drawing api.

Edit: I had some time on my hands, so I wrote up a quick script :slight_smile:


onLoad = function() {
	createEmptyMovieClip("dandilion", 1);
	dandilion.lineStyle(1, 0x000000, 100);
	width = 150;
	
	lines = 100;
	for(i=0; i<lines; i++) {
		dandilion.createEmptyMovieClip("line"+i, i);
		dandilion["line"+i].lineStyle(1, 0x000000, 100);
		dandilion["line"+i].moveTo(0-(width/2), 0);
		dandilion["line"+i].lineTo((width/2), 0);
		dandilion["line"+i]._rotation = (i*(360/lines));
	}
	dandilion._x = Stage.width/2;
	dandilion._y = Stage.height/2;
}

It will create a dandilion in centered on the stage. If you change the width variable, it will change the diameter of the dandilion, and the lines variable will change the number of lines used in the circle.

Hope this helps :slight_smile:

OH MY GOD!! YOU ARE A TRUE SAINT!!! Can you please contact me via AIM, twenty2strangers. I would like to talk to you more about scripting. This is only the beginning of what I want to do.

I need the dandilion to be three dimensional and rotate based on the mouse movement.

If I used the following code with the line being just a plain white line. How would I modify it so that the mouse interaction was more smooth? And what would I have to scale this up to say 500 data points?

Points = 11;
Lines = 10;

Viewport = 500;

rad = (3.14*2)/260;

line = new Array(Lines);
vertex = new Array(Points);

fscommand (“fullScreen”, true);

for (i=0; i != Lines; i++) {
wire.DuplicateMovieClip(“l” add i, i);
line* = eval(“l” add i);
}
for (i=0; i != Points; i++) {
point.DuplicateMovieClip(“v” add i, (Lines2)+i);
vertex
= eval(“v” add i);
}

vertex[0].x = 0;
vertex[1].x = -100;
vertex[2].x = -150;
vertex[3].x = -150;
vertex[4].x = 0;
vertex[5].x = 100;
vertex[6].x = 150;
vertex[7].x = 100;
vertex[8].x = 150;
vertex[9].x = 0;
vertex[10].y = 0;
vertex[0].y = 0;
vertex[1].y = -100;
vertex[2].y = 0;
vertex[3].y = 100;
vertex[4].y = 150;
vertex[5].y = 100;
vertex[6].y = 0;
vertex[7].y = -100;
vertex[8].y = -150;
vertex[9].y = 0;
vertex[10].y = 0;
vertex[0].z = 0;
vertex[1].z = -100;
vertex[2].z = 0;
vertex[3].z = 100;
vertex[4].z = 0;
vertex[5].z = 100;
vertex[6].z = 0;
vertex[7].z = -100;
vertex[8].z = 0;
vertex[9].z = -150;
vertex[10].z = 150;

line[0].a = 0;
line[0].b = 1;
line[1].a = 0;
line[1].b = 2;
line[2].a = 0;
line[2].b = 3;
line[3].a = 0;
line[3].b = 4;
line[4].a = 0;
line[4].b = 5;
line[5].a = 0;
line[5].b = 6;
line[6].a = 0;
line[6].b = 7;
line[7].a = 0;
line[7].b = 8;
line[8].a = 0;
line[8].b = 9;
line[9].a = 0;
line[9].b = 10;

function Rotate (x, y, z) {
radx = radx;
rady = rad
y;
radz = radz;
for (i=0; i != Points; i++) {
vertex
.x1 = vertex*.x;
vertex*.y1 = (Math.cos(radx)vertex.y)-(Math.sin(radx)vertex.z);
vertex*.z1 = (Math.sin(radx)vertex.y)+(Math.cos(radx)vertex.z);
vertex*.x2 = (Math.cos(rady)vertex.x1)-(Math.sin(rady)vertex.z1);
vertex*.y2 = vertex*.y1;
vertex*.z2 = (Math.sin(rady)vertex.x1)+(Math.cos(rady)vertex.z1);
vertex*.x3 = (Math.cos(radz)vertex.x2)-(Math.sin(radz)vertex.y2);
vertex*.y3 = (Math.sin(radz)vertex.x2)+(Math.cos(radz)vertex.y2);
vertex*.z3 = vertex*.z2;
}
}

function toScreen () {
for (i=0; i != Points; i++) {
vertex*.dx = (vertex*.x3viewport)/(vertex.z3+600)+350;
vertex*.dy = (vertex*.y3viewport)/(vertex.z3+600)+262.5;
}
}

function render () {
for (i=0; i != lines; i++) {
with (line*) {
_visible = true;
_x = vertex[line*.a].dx;
_y = vertex[line*.a].dy;
_xscale = vertex[line*.b].dx-vertex[line*.a].dx;
_yscale = vertex[line*.b].dy-vertex[line*.a].dy;
}
}
for (i=0; i != points; i++) {
with (vertex*) {
_x = dx;
_y = dy;
_xscale = 75+(((((500-z3*)/10)30)/100)(-1));
_yscale = 75+(((((500-z3*)/10)30)/100)(-1));
_alpha = ((((z3**(-1))+500)/10));
}
}
}

var ax, ay, az, oldx, oldy, bx, by, bz, nu;

set (circleplay, 0);

I got this code from this tutorial: http://www.flashkit.com/tutorials/3D/3D_Flowe-V_Ramra-801/index.php

Also how do I make all of the lines the same length so that it looks more like a sphere and less like the asteriks. I am aware that some lines are shorter for perspective, but it just doesn’t look like a sphere.

Heh. Sorry, I can’t help you there, I haven’t gotten into the whole 3d thing yet. :wink:

Edit: And I looked at that tutorial just now, and it’s for Flash 5 :wink: You might want to have a look at some of senocular’s tutorials on Kirupa about 3d in flash.

http://www.bit-101.com he has by far the best introduction to 3d tutorial. PM me if you want some help on the 3d… (I can probably give you a hand if I have some free time)