Experiment: Shape Points

[swf=“http://www.skehin.com/misc/points.swf height=400 width=400”][/swf]

This is my first posted flash experiment, other than my footers… Source code
below :slight_smile:

Also, feel free to move this if it isn’t in the right place. I wasn’t sure where to post this in the in the first place.
[AS]
this.createEmptyMovieClip(“drawing_mc”, 1000);
drawing_mc._x = 0; drawing_mc._y = 0;
var xArray_array = [0];
var yArray_array = [0];
for (var i = 0; i<(random(10)+10); i++) {
xArray_array.push(random(401));
yArray_array.push(random(401));
}
drawing_mc.lineStyle(1, 0x000000, 100);
drawing_mc.moveTo(xArray_array[0], yArray_array[0]);
this.onMouseDown = function() {
drawing_mc.removeMovieClip();
this.createEmptyMovieClip(“drawing_mc”, 1000);
drawing_mc._x = 0; drawing_mc._y = 0;
var xArray_array = [0];
var yArray_array = [0];
for (var i = 0; i<(random(10)+10); i++) {
xArray_array.push(random(401));
yArray_array.push(random(401));
}
drawing_mc.lineStyle(1, 0x000000, 100);
for (var i = 0; i<xArray_array.length; i++) {
for (var h = 0; h<yArray_array.length; h++) {
drawing_mc.lineTo(xArray_array[h], yArray_array[h]);
drawing_mc.moveTo(xArray_array*, yArray_array*);
}
}
};
for (var i = 0; i<xArray_array.length; i++) {
for (var h = 0; h<yArray_array.length; h++) {
drawing_mc.lineTo(xArray_array[h], yArray_array[h]);
drawing_mc.moveTo(xArray_array*, yArray_array*);
}
}

[/AS]

Ok nice, but there isn’t something “crazy”, you’re just connecting lines from what I’m seeing, njs, I would instead make it more “interactive” and add events and such…

Anyhow, Good Job. :slight_smile:

it would be nice if you could add a refresh on like a mouse click or with a button or something :slight_smile:

thats cool but i agree with the refresh thing.

Done. :wink:

You might have to clear your cache though. (Tools->Internet Options->Clear Files)

Also, when I post swfs I don’t see the file, all I see is blank space the size of the swf. If I right-click the space, I see “Movie not loaded” and the rest of the flash player menu.

njs,

Add this instead,

[<i></i>swf=“http://www.skehin.com/misc/points.swf height=400 width=400”][/swf]

How about

NUM_DOTS = 10 ;
dot_arr = [] ;
this.createEmptyMovieClip ( "drawing", -1 ) ;

MovieClip.prototype.moveRandom = function () {
	var dx = this.targx - this._x ;
	var dy = this.targy - this._y ;
	this._x += dx / 5 ;
	this._y += dy / 5 ;
	if ( Math.abs(dx) + Math.abs(dy) < 10 ) {
		this.targx = random (400) ;
		this.targy = random (400) ;
	}
}
function generatePoints () {
	for ( var i = 0 ; i < NUM_DOTS ; i++ ) {
		dot_arr.push ( this.createEmptyMovieClip ( "d" + i, i ) ) ;
		dot_arr*.targx = dot_arr*._x = random (400) ;
		dot_arr*.targy = dot_arr*._y = random (400) ;
		dot_arr*.onEnterFrame = moveRandom ;
	}
}
function renderLines () {
	drawing.clear () ;
	drawing.lineStyle ( 0 ) ;
	for ( var j = 0 ; j < NUM_DOTS ; j++ ) {
		for ( var k = j+1 ; k < NUM_DOTS ; k++ ) {
			drawing.moveTo ( dot_arr[j]._x, dot_arr[j]._y ) ;
			drawing.lineTo ( dot_arr[k]._x, dot_arr[k]._y ) ;
		}
	}
}
generatePoints () ;
this.onEnterFrame = renderLines ;

pom :slight_smile:

Pretty cool animation there njs :wink:

Wow Ilyas, that code is amazing! I could never write something like that! I hope one day I’m as good at scripting as you.

its a lot like lost’s random points in kirupa-lab. Have you seen that njs?

http://www.kirupa.com/lab/randompoints.htm

would be nice if the lines eased into new shape instead of just appearing in new position. Other than that, very nice work!

(and yes, i think i will join you on the ‘wanting to script like Ilyas’ thought)

Orange, yeah, that’s what Ilyas’s one does.

Yeah, I’ve seen that experiment before. It’s a pretty nice script (although coming from Lost, you would expect it to be).

Yep, it looks a bit like Lost’s experiment. I guess the functions look a bit alike, the main difference being in the number of lines drawn :slight_smile:

And the code is not really complicated. All you have to do, really, is to use complicated names, like render, or generate instead of draw and make:wink: