# Sphere made up of 1000 lines?

**URL:** <https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407>\
**Category:** flash\
**Created:** [July 22, 2004, 4:31am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407 "2004-07-22T04:31:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mastawok](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mastawok](https://forum.kirupa.com/u/mastawok)\
**Post date:** [July 22, 2004, 4:31am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/1 "2004-07-22T04:31:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 4:46am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/2 "2004-07-22T04:46:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 4:54am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/3 "2004-07-22T04:54:42Z")

</div>

> [@Krilnon](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 5:16am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/4 "2004-07-22T05:16:06Z")

</div>

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 🙂

```auto

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 6:25am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/5 "2004-07-22T06:25:30Z")

</div>

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.

> [@Yeldarb](#):
>
> 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 🙂
> 
> ```auto
> 
> 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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 6:31am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/6 "2004-07-22T06:31:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 6:41am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/7 "2004-07-22T06:41:40Z")

</div>

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, (Lines_2)+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 = rad_x;  
rady = rad_y;  
radz = rad_z;  
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\*.x3_viewport)/(vertex_.z3+600)+350;  
vertex\*.dy = (vertex\*.y3_viewport)/(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);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 6:43am UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/8 "2004-07-22T06:43:19Z")

</div>

I got this code from this tutorial: [http://www.flashkit.com/tutorials/3D/3D\_Flowe-V\_Ramra-801/index.php](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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 3:46pm UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/9 "2004-07-22T15:46:33Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2004, 10:39pm UTC](https://forum.kirupa.com/t/sphere-made-up-of-1000-lines/58407/10 "2004-08-11T22:39:13Z")

</div>

[http://www.bit-101.com](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)
