View Full Version : Mouse toy
Headshotz
01-19-2006, 03:49 AM
Heyo,
In this challenge, try and make something cool that interacts with the mouse, you know, mouse toy :)
If you have no idea what Im talking about try this example (paste in frame):
//==========
//*~HeadshotZ~*\\
//==========
_root.createEmptyMovieClip("bg_mc", 0);
var stagewidth = 550;
var stageheight = 400;
bg_mc.beginFill(0x000000, 75);
bg_mc.lineTo(0, 0);
bg_mc.lineTo(stagewidth, 0);
bg_mc.lineTo(stagewidth, stageheight);
bg_mc.lineTo(0, stageheight);
bg_mc.endFill();
_root.createEmptyMovieClip("tracer0_mc", _root.getNextHighestDepth());
tracer0_mc.beginFill(0xFF0000, 75);
tracer0_mc.lineTo(0, 0);
tracer0_mc.lineTo(10, 0);
tracer0_mc.lineTo(10, 10);
tracer0_mc.lineTo(0, 10);
tracer0_mc.lineTo(0, 0);
nm = .03;
k = 1;
_root.onEnterFrame = function() {
for (k=1; k<10; k++) {
tracer0_mc._x += (_xmouse-tracer0_mc._x)*nm;
tracer0_mc._y += (_ymouse-tracer0_mc._y)*nm;
_root["tracer"+k+"_mc"]._x += (_root["tracer"+(k-1)+"_mc"]._x-_root["tracer"+k+"_mc"]._x)*nm;
_root["tracer"+k+"_mc"]._y += (_root["tracer"+(k-1)+"_mc"]._y-_root["tracer"+k+"_mc"]._y)*nm;
}
};
i = 1;
for (i=1; i<10; i++) {
tracer0_mc.duplicateMovieClip("tracer"+i+"_mc", i+100);
}
Enjoi
*~HeadshotZ~*
invader
01-19-2006, 04:58 AM
it could have lived without the background, but it adds a nice touch
you should have used a loop:
for (i=2;i<=10;i++)
{
this.["tracer_mc"+i]._x += (this.["tracer_mc"+(i-1)]._x-this.["tracer_mc"+i]._x)*nm;
this.["tracer_mc"+i]._y += (this.["tracer_mc"+(i-1)]._y-this.["tracer_mc"+i]._y)*nm;
}
if you had named the first one "tracer_mc0" or something, you could loop for 1, but that for() loop will just do #2-10
i'll see if i have time to whip up something interesting in the next day or two
astgtciv
01-20-2006, 02:57 AM
Here is my contribution (paste into frame):
lineStyle(0);
moveTo(Stage.width/2, Stage.height/2);
function onEnterFrame() {
lineTo(_xmouse, _ymouse);
_rotation += 1;
}
You can draw continents as if it was a map :). Wait long enough and it will come back to you...
invader
01-21-2006, 12:27 AM
inspired by astgtciv, i thought i would make something that draws similarly, but also shrinks toward the center each frame.. i was impressed that it only took 16 lines:
createEmptyMovieClip("mc",0);
mc._x = Stage.width/2;
mc._y = Stage.height/2;
arr = new Array();
function onEnterFrame() {
arr[arr.length]=[mc._xmouse,mc._ymouse];
mc.clear();
mc.lineStyle(0);
mc.moveTo(arr[arr.length-1][0],arr[arr.length-1][1]);
for (i=arr.length-2;i>=0;i--) {
a = (Math.acos(arr[i][0]/Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2)))*arr[i][1]/Math.abs(arr[i][1]));
arr[i][0] = Math.cos(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95;
arr[i][1] = Math.sin(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95;
mc.lineTo(arr[i][0],arr[i][1]);}
for (i=30;i<arr.length;i++)
arr = arr.slice(1);}
astgtciv
01-21-2006, 07:44 AM
Awesome, invader! And another tiny upgrade (are we still in the line limit?):
createEmptyMovieClip("mc",0);
mc._x = Stage.width/2;
mc._y = Stage.height/2;
arr = new Array();
function onEnterFrame() {
arr[arr.length]=[-mc._xmouse,-mc._ymouse];
mc.clear();
mc.lineStyle(0);
mc.moveTo(arr[arr.length-1][0],arr[arr.length-1][1]);
mc.beginFill(random(0xFFFFFF));
for (i=arr.length-2;i>=0;i--) {
a = (Math.acos(arr[i][0]/Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2)))*arr[i][1]/Math.abs(arr[i][1]));
arr[i][0] = (mc._xmouse + Math.cos(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;
arr[i][1] = (mc._ymouse + Math.sin(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;
mc.lineTo(arr[i][0],arr[i][1]);
}
mc.endFill();
for (i=30;i<arr.length;i++)
arr.shift();
}
Flash Gordon
01-21-2006, 07:48 AM
Awesome, invader! And another tiny upgrade (are we still in the line limit?):uuu......Acid trip!
Nice work so far guys!
astgtciv
01-21-2006, 07:57 AM
I was just gonna say something about drugs ;) this version looks like some kind of an animation technique:
createEmptyMovieClip("mc",0);
mc._x = Stage.width/2;
mc._y = Stage.height/2;
arr = new Array();
function onEnterFrame() {
arr[arr.length]=[mc._xmouse,mc._ymouse];
mc.clear();
mc.lineStyle(0);
mc.moveTo(arr[arr.length-1][0],arr[arr.length-1][1]);
mc.beginFill(random(0xFFFFFF));
for (i=arr.length-2;i>=0;i--) {
a = (Math.acos(arr[i][0]/Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2)))*arr[i][1]/Math.abs(arr[i][1]));
arr[i][0] = (mc._xmouse + Math.cos(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;
arr[i][1] = (mc._ymouse + Math.sin(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;
mc.lineTo(arr[i][0]/(1+Math.random()/4),arr[i][1]/(1+Math.random()/4));
}
mc.endFill();
for (i=30;i<arr.length;i++)
arr.shift();
}
invader
01-22-2006, 02:35 AM
wow! those are pretty intense
that's one of the cool things about working with trigonometric functions, they can go crazy and sometimes look quite cool!
Headshotz
01-22-2006, 06:00 AM
Nice work everyone so far, keep them coming.
it could have lived without the background, but it adds a nice touch
you should have used a loop:
...
if you had named the first one "tracer_mc0" or something, you could loop for 1, but that for() loop will just do #2-10
i'll see if i have time to whip up something interesting in the next day or two
Yeah I changed it.
invader
01-23-2006, 12:24 AM
Yeah I know, I told you crappy example.
Ill add something good.
there was nothing wrong with the example. i was just recommending a way to optimize it a little bit
Headshotz
01-25-2006, 09:32 PM
Too much code to allow on the forums, but I made a small 'thank you' application for the guys at MRM that taught me PHP.
Heres the .swf + source
astgtciv
01-25-2006, 10:36 PM
How cute!!! The first part reminds me of http://www.liquidjourney.com/ ...
Nice!
Headshotz
01-25-2006, 10:39 PM
Hehe, thanks.
Keep those entries coming :)
daperson
01-27-2006, 12:32 PM
hey,i like the example, can i use it in my flashgame? :P
Headshotz
01-28-2006, 04:51 AM
Anyone else have anything they want to contribute?
Headshotz
01-28-2006, 04:53 AM
hey,i like the example, can i use it in my flashgame? :P
Is that a serious question and what example were you talking about?
drexle
01-29-2006, 05:57 AM
He's talking about this:
http://www.actionscript.org/forums/showthread.php3?t=94623
drexle
01-29-2006, 12:07 PM
Sigh. I'm not cool enough to come up with something less than 25 lines of code yet, but I did make what is probably my first 100% code based thingy as a result of wanting to try this.
It works well enough, but not presicely the way I want it to.
daperson
01-29-2006, 08:48 PM
its a seirous question, its game game that gets linked to by that other guys pos
zap1992
01-29-2006, 10:14 PM
Hey guys, ever seen me here? didnt think so :) heres mine and at about 24 lines it looks pretty cool(put it in a blank normal size movie)
//Cool, eh?
//Set up generic tealish triangle at 80% alpha
done = true;
_root.createEmptyMovieClip("obj", 0);
obj.beginFill(0xB8FDDD, 80);
obj.lineTo(-20, 0);
obj.lineTo(5, 7);
obj.lineTo(10, 0);
obj.lineTo(0, 0);
//Draw a blue movieclip to overlap the background
_root.createEmptyMovieClip("bck", 1);
bck.beginFill(0x011CB4, 100);
bck.lineTo(0,0)
bck.lineTo(550,0)
bck.lineTo(550,400)
bck.lineTo(0,400)
bck.lineTo(0,0)
//Set up the count variable
count = 2
function onEnterFrame() {
//Add to the generic objects rotation so the newly spawned ones will be different
_root.obj._rotation += 20
//create a new object and set its rate of falling to -12
count ++
obj.duplicateMovieClip("obj" + count, count)
_root["obj"+count]._x = _root._xmouse
_root["obj"+count]._y = _root._ymouse
_root["obj"+count].fall = -12
//update each object
for(x = 0;x<=count;x++) {_root["obj"+x]._alpha -= 3 ;}
//make each object fall,rise based on it's rate of falling
for(x = 0;x<=count;x++) {_root["obj"+x]._y += _root["obj"+x].fall;_root["obj"+x].fall += 1}
}
Headshotz
01-30-2006, 04:18 AM
:) Very nicely done.
Anyone can use my codes I post on Actionscript.org for anything
astgtciv
01-30-2006, 07:56 AM
Cool one, zap!
here's another one (requires flash 8 tho :()
just playing around with the colorgradients there
import flash.geom.*
var CNTRL_RAND=15;
var radius=100;
var controlOffset:Object = {x:(Math.random()-0.5)*2*radius, y:(Math.random()-0.5)*2*radius};
var mc=createEmptyMovieClip("mc", this.getNextHighestDepth());
function onEnterFrame() {
with(mc){
clear();
matrix = new Matrix();
matrix.createGradientBox(_xmouse-Stage.width/2, _ymouse-Stage.height/2, Math.PI, 0, 0);
beginGradientFill("radial", [0xFF0000, 0x0000FF], [100, 100], [0, 0xFF], matrix, "reflect", "linearRGB", 0.9);
moveTo(_xmouse-radius, _ymouse);
curveTo(_xmouse-controlOffset.x, _ymouse-controlOffset.y, _xmouse, _ymouse-radius);
curveTo(_xmouse+controlOffset.x, _ymouse-controlOffset.y,_xmouse+radius, _ymouse);
curveTo(_xmouse+controlOffset.x, _ymouse+controlOffset.y, _xmouse, _ymouse+radius);
curveTo( _xmouse-controlOffset.x, _ymouse+controlOffset.y,_xmouse-radius, _ymouse);
endFill();
_rotation += 10;
}
controlOffset.x += (Math.random()-0.5)*CNTRL_RAND;
controlOffset.y += (Math.random()-0.5)*CNTRL_RAND;
radius = Math.min(Stage.width, Math.max(Stage.height/5,radius+(Math.random()-0.5)*CNTRL_RAND));
}
zap1992
01-30-2006, 03:48 PM
umm... it doesnt do anything? I have MX 2004 :-/
oh and guys... I had a really awesome one taht looked like silk, ill try to make it again... (mx crashed and I never saved it =-O)
Headshotz
01-30-2006, 10:42 PM
Whoa thats pretty cool ;)
zap1992
01-31-2006, 02:17 AM
=D
not Quite like it was before but still really cool. Press up and down repeateadly to increase/decrease elasticity. The higher it is, the less the balls are attracted to the center. (note,you can go below 0, do if they suddenly explode off the screen....ya...)
e=100
i=0
_root.createEmptyMovieClip(background,0)
beginFill(0x000000)
lineTo(0,0)
lineTo(550,0)
lineTo(550,400)
lineTo(0,400)
lineTo(0,1)
_root.createEmptyMovieClip("obj",1)
with(obj){lineStyle(15,0x0099FF);
lineTo(.5,0);
_x = -500;
_y = 200;}
for(x=2;x<=216;x++) {obj.duplicateMovieClip("obj"+x,100+x);
_root["obj"+x]._x = 200;}
function onEnterFrame() {
_root.obj216._y = _root._ymouse
_root.obj216._x = _root._xmouse
for(x=215;x>1;x--) {with(_root["obj"+x]) {_y = (_root["obj" + number(x+1)]._y*e + _y*e + 200)/ (e*2 + 1)
_x = (_root["obj" + number(x+1)]._x*e + _x*e + 200)/ (e*2 + 1)}}
if (Key.isDown(38) && d == false) { d = true; e+= 5} else {d= false}
if (Key.isDown(40) && u == false) { u = true; e-= 5} else {u= false}}
Headshotz
01-31-2006, 08:28 AM
:)
Well done.
Ross111
03-05-2006, 09:12 PM
Heres A Rather Rubbish One But Hey, I Only Started Actiosncripting A Couple Of Weeks Ago...
mouseInterval = setInterval(mouseToy, 10);
function mouseToy() {
stick.clear();
this.createEmptyMovieClip("stick", this.getNextHighestDepth);
stick.lineStyle(1, 0xFF0000);
stick.beginFill(0x0000FF, 100);
stick.moveTo(_root._xmouse, _root._ymouse);
stick.lineTo(Math.round(Math.random()*550), Math.round(Math.random()*400));
stick.lineTo(Math.round(Math.random()*550), Math.round(Math.random()*400));
stick.lineTo(_root._xmouse, _root._ymouse);
stick.endFill();
}
mouseToy();
Flash 6 and Above...
MichaelxxOA
03-08-2006, 05:29 AM
Fun Fun Fun.. here you go ;)
var line_size = 1;
var new_line_size = 10;
var max_line_sizes = [20, 40];
var line_color = Math.round(Math.random()*0xFFFFFF);
var line_alpha = 100;
var intID = setInterval(adjustLineSize, Math.round(Math.random()*1000)+1000, Math.random()*max_line_sizes[0]);
var pen:Object = new Object();
pen.newX = _xmouse;
pen.newY = _ymouse;
pen.x = _xmouse;
pen.y = _ymouse;
pen.onMouseMove = draw;
Mouse.addListener(pen);
this.lineTo(pen.x, pen.y);
function onEnterFrame() {
pen.newX = _xmouse;
pen.newY = _ymouse;
line_size += (new_line_size-line_size)/10;
pen.x += (pen.newX-pen.x)/10;
pen.y += (pen.newY-pen.y)/10;
this.lineStyle(line_size, line_color, line_alpha);
this.lineTo(pen.x, pen.y);
this.lineStyle(line_size+5, 0xFFFFFF, 100);
this.lineTo(pen.x+1, pen.y);
this._rotation += 2;
}
function adjustLineSize(size) {
clearInterval(intID);
new_line_size = size;
max_line_sizes.reverse();
intID = setInterval(adjustLineSize, Math.round(Math.random()*1000)+1000, Math.random()*max_line_sizes[0]);
}
Enjoy!
_Michael
FPS of 30!
onMouseDown = function () {
for (i=0; i<10; i++) {
_mc = _root.createEmptyMovieClip("_mc"+i, _root.getNextHighestDepth());
make(_mc);
}
};
var dir:Array = [-1, 1];
function make(_mc) {
_mc.moveTo(_root._xmouse, _root._ymouse);
t = Math.floor(Math.random()*10)+10;
r = Math.floor(Math.random()*99);
b = Math.floor(Math.random()*99);
g = Math.floor(Math.random()*99);
X = "0x"+r+""+b+""+g;
_mc.lineStyle(t, X, 100);
_mc.lineTo((_root._xmouse+.5), _root._ymouse);
_mc.num = -1*Math.floor(Math.random()*10);
_mc.num2 = dir[(Math.floor(Math.random()*2))];
_mc.onEnterFrame = function() {
this._y += ++this.num;
this._x += (this.num2*2.6);
if (this._y>800) {
delete this.onEnterFrame;
this.removeMovieClip();
}
};
}
Headshotz
03-08-2006, 08:24 AM
Nice work :)
Heres a simple one for flash 8:
//HeadshotZ || LeViAtHaN \\
//
import flash.filters.BlurFilter;
//
_root.createEmptyMovieClip("bg_mc", 0);
_root.createEmptyMovieClip("sq_mc", 1);
//
var bg_arr:Array = [[0, 0], [Stage.width, 0], [Stage.width, Stage.height], [0, Stage.height], [0, 0]];
var sq_arr:Array = [[-5, -5], [5, -5], [5, 5], [-5, 5], [-5, -5]];
var random_arr:Array = [[random(550), random(400)]];
var blurred:BlurFilter = new BlurFilter(3, 3, 10);
var v:Number = 0.03;
//
bg_mc.beginFill(0x000000, 75);
sq_mc.beginFill(0x00CC00, 100);
//
for (xtg = 0; xtg <= bg_arr.length; xtg++) {
bg_mc.lineTo(bg_arr[xtg][0], bg_arr[xtg][1]);
sq_mc.lineTo(sq_arr[xtg][0], sq_arr[xtg][1]);
}
sq_mc._width = 30;
sq_mc._height = 30;
//
function blurWhile() {
sq_mc.filters = [blurred];
var xcontrol:Number = (_xmouse - sq_mc._x) * v;
var ycontrol:Number = (_ymouse - sq_mc._y) * v;
sq_mc._x += xcontrol;
sq_mc._y += ycontrol;
if (xcontrol > 0) {
sq_mc._rotation += xcontrol;
blurred.blurX = xcontrol;
} else if (xcontrol < 0) {
sq_mc._rotation -= xcontrol;
blurred.blurX = (xcontrol *= -1);
}
if (ycontrol > 0) {
sq_mc._rotation += ycontrol;
blurred.blurY = ycontrol;
} else if (ycontrol < 0) {
sq_mc._rotation -= ycontrol;
blurred.blurY = (ycontrol *= -1);
}
}
//
onEnterFrame = blurWhile;
Heres one for MX 2004 or higher:
//LeviathaN || HeadshotZ
_root.createEmptyMovieClip("bg_mc", 0);
_root.createEmptyMovieClip("line_mc", 1);
_root.createTextField("disp_txt", 2, 0, 0, 500, 30);
i = 0;
c = 0;
var firstrun = true;
var mousedown = false;
var drawing = true;
var cont = true;
my_fmt = new TextFormat();
my_fmt.bold = true;
my_fmt.color = 0xFF9900;
bg_mc.beginFill(0x000000, 75);
bg_mc.lineTo(0, 0);
bg_mc.lineTo(Stage.width, 0);
bg_mc.lineTo(Stage.width, Stage.height);
bg_mc.lineTo(0, Stage.height);
bg_mc.lineTo(0, 0);
line_mc.lineStyle(2, 0xFFFFFF, 75);
xpos_arr = [];
ypos_arr = [];
onMouseDown = function () {
if (cont) {
if (firstrun) {
line_mc.moveTo(_xmouse, _ymouse);
firstrun = false;
}
} else {
line_mc.moveTo(_xmouse, _ymouse);
firstrun = false;
}
xpos_arr = [_xmouse];
ypos_arr = [_ymouse];
mousedown = true;
drawing = false;
};
onMouseUp = function () {
c = 0;
mousedown = false;
drawing = true;
};
_root.onEnterFrame = function() {
if (mousedown) {
xpos_arr.push(_xmouse);
ypos_arr.push(_ymouse);
}
if (drawing) {
if (c<xpos_arr.length || c<ypos_arr.length) {
line_mc.lineTo(xpos_arr[c], ypos_arr[c]);
c++;
}
}
if (cont) {
disp_txt.text = "Continual line mode";
disp_txt.setTextFormat(my_fmt);
} else {
disp_txt.text = "Seperate line mode";
disp_txt.setTextFormat(my_fmt);
}
if (Key.isDown(Key.SPACE)) {
line_mc.clear();
line_mc.lineStyle(2, 0xFFFFFF, 75);
firstrun = true;
}
if (Key.isDown(Key.UP)) {
cont = true;
}
if (Key.isDown(Key.DOWN)) {
cont = false;
}
};
Dylan Marvin
03-16-2006, 04:19 PM
Killing two birds with one stone, as they say. First I wanted to create in lines the robot arm effect (two lines jointed together follow mouse without changing lengths) and to create the most user-unfriendly math ever for the sake of using less lines of code.
function onEnterFrame() {
armLength = 100;
xDist = _root._xmouse-(Stage.width/2);
yDist = _root._ymouse-(Stage.height/2);
radians3 = ((-1*((Math.acos((.5*Math.round(Math.sqrt(xDist*xDist +yDist*yDist)))/armLength))*180/Math.PI))-(360-(Math.atan2((_root._ymouse-(Stage.height/2)), (_root._xmouse-(Stage.width/2))))*180/Math.PI))*(Math.PI/180);
xcoordinate = (Stage.width/2)+armLength*Math.cos(radians3);
ycoordinate = (Stage.height/2)+armLength*Math.sin(radians3);
createEmptyMovieClip("arm", 0);
arm.clear();
arm.lineStyle(3, 0x999999, 100);
arm.moveTo(200, 200);
arm.lineTo(xcoordinate, ycoordinate);
arm.lineTo(_root._xmouse, _root._ymouse);
}
Headshotz
03-19-2006, 01:03 AM
:D Cool
darkzak
03-25-2006, 07:17 PM
var NUM_CIRCLES = 40;
for (var i = 0; i < NUM_CIRCLES; i++)
createCircle(0, 0, (i/NUM_CIRCLES)*80+20, (i/NUM_CIRCLES)*20+1, (NUM_CIRCLES -i)/NUM_CIRCLES*4+2, i);
displayInterval = setInterval(display, 5);
dest_array = new Array({x:_xmouse, y:_ymouse});
removedIndex = 0;
function display()
{
for (var i = 0; i < NUM_CIRCLES; i++)
{
var mc = _root["circle" +i];
mc.actualDestIndex = mc.destIndex - removedIndex;
mc._x += (dest_array[mc.actualDestIndex].x - mc._x)/mc.speed;
mc._y += (dest_array[mc.actualDestIndex].y - mc._y)/mc.speed;
if (Math.abs(dest_array[mc.actualDestIndex].x - mc._x) < 3 &&
Math.abs(dest_array[mc.actualDestIndex].y - mc._y) < 3)
{
mc.destIndex = (mc.actualDestIndex == (dest_array.length-1))?mc.destIndex:++mc.destIndex;
if (mc == _root["circle" + Math.floor(NUM_CIRCLES-1)] &&
mc.actualDestIndex == (dest_array.length-1) &&
(Math.abs(dest_array[mc.actualDestIndex].x - _xmouse) > 2 ||Math.abs(dest_array[mc.actualDestIndex].y - _ymouse) > 2))
dest_array.push({x:_xmouse, y:_ymouse});
else if (mc == _root.circle0 && dest_array.length > 1
&& mc.actualDestIndex != _root["circle" + Math.floor(NUM_CIRCLES-1)].actualDestIndex)
{
removedIndex++;
dest_array.shift();
}
}
}
updateAfterEvent();
}
function createCircle(x, y, alpha, diameter, speed, index)
{
var circleClip = _root.createEmptyMovieClip("circle" + index, index+1);
circleClip.lineStyle(diameter, 0xFF0000, alpha);
circleClip.moveTo(0,0);
circleClip.lineTo(0,1);
circleClip._x = x;
circleClip._y = y;
circleClip.speed = speed;
circleClip.destIndex = 0;
}
darkzak
03-25-2006, 09:20 PM
Here is another version that uses lines to chase the mouse pointer.
var NUM_LINES = 40;
var linesArray = new Array();
for (var i = 0; i < NUM_LINES; i++)
linesArray.push({speed:(NUM_LINES -i)/NUM_LINES*4+1, x:0, y:0, width:(i/NUM_LINES)*20+1, alpha:(i/NUM_LINES)*80+20, destIndex:0, actualDestIndex:0});
displayInterval = setInterval(display, 5);
dest_array = new Array({x:_xmouse, y:_ymouse});
removedIndex = 0;
function display()
{
_root.clear();
var prevLine = linesArray[0];
for (var i = 0; i < NUM_LINES; i++)
{
var curLine = linesArray[i];
//keep track of which index is the current one
prevLine.actualDestIndex = prevLine.destIndex - removedIndex;
curLine.actualDestIndex = curLine.destIndex - removedIndex;
_root.lineStyle(1, 0x000000, curLine.alpha);
curLine.x += (dest_array[curLine.actualDestIndex].x - curLine.x)/curLine.speed;
curLine.y += (dest_array[curLine.actualDestIndex].y - curLine.y)/curLine.speed;
_root.moveTo(prevLine.x, prevLine.y);
_root.lineTo(curLine.x+1, curLine.y);
if (Math.abs(dest_array[curLine.actualDestIndex].x - curLine.x) < 3 &&
Math.abs(dest_array[curLine.actualDestIndex].y - curLine.y) < 3)
{
curLine.destIndex = (curLine.actualDestIndex == (dest_array.length-1))?curLine.destIndex:++curLine.destIndex;
if (curLine == linesArray[NUM_LINES-1] &&
curLine.actualDestIndex == (dest_array.length-1) &&
(Math.abs(dest_array[curLine.actualDestIndex].x - _xmouse) > 2 ||Math.abs(dest_array[curLine.actualDestIndex].y - _ymouse) > 2))
dest_array.push({x:_xmouse, y:_ymouse});
else if (curLine == linesArray[0] && dest_array.length > 1
&& curLine.actualDestIndex != linesArray[NUM_LINES-1].actualDestIndex)
{
removedIndex++;
dest_array.shift();
}
}
prevLine = curLine;
}
updateAfterEvent();
}
icemart525
03-28-2006, 09:17 AM
i like the red circles by darkzak, it's like i've been hit in the head when staring at them.
Headshotz
03-30-2006, 11:30 PM
good work =)
Flash Gordon
04-13-2006, 07:50 AM
// code
that is ridiculous!
Headshotz
04-13-2006, 10:50 AM
lol.
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.