PDA

View Full Version : lines going in and out of depth


mattkenefick
07-06-2007, 08:28 PM
I'm sure you've all seen those flash things where lines and swirling all over the place.. The go at angles, in and out of depths like you're racing along with it.. the curl and what not..


I'm looking to write some code to create lines like that.. Anyone interested in workin on it?

I'll start up with some in a reply to this soon.

mattkenefick
07-07-2007, 12:23 AM
Heres a quick rush of an example just to get the right idea in mind:


Just paste and it should do the trick.




import flash.display.BitmapData
import flash.geom.Rectangle


with(_root){
lineStyle(1,0xFF0000,50);
beginFill(0x0,50);
moveTo(300,200);
lineTo(320,200);
lineTo(320,220);
lineTo(300,220);
lineTo(300,200);
endFill();
}


var bmp:BitmapData = new BitmapData(Stage.width, Stage.height, true, 0x000000);

_root.attachBitmap(bmp,1);

_root.vx = 1
_root.vy = 0

onEnterFrame = function(){
bmp.draw(_root)
bmp.scroll(_root.vx,_root.vy)
}


var waiter = 0;
var currentTime = 0;

setInterval(
function(){
waiter++;

if(waiter==timesOfChange[currentTime].a){
_root.vx+= timesOfChange[currentTime].x;
_root.vy+= timesOfChange[currentTime].y;
waiter=0
currentTime++;
}
},100);


var timesOfChange = [

{a:10,x:1,y:2},
{a:5,x:1,y:-1},
{a:5,x:0,y:-2},
{a:5,x:-1,y:2},
{a:1,x:-1,y:2},
{a:1,x:-1,y:0},
{a:1,x:-1,y:1},
{a:1,x:-1,y:0},
{a:2,x:0,y:-1},
{a:3,x:0,y:-2},
{a:3,x:3,y:0},
{a:2,x:1,y:2},
{a:3,x:1,y:-1},
{a:5,x:0,y:-2},
{a:5,x:-1,y:0},
{a:1,x:-1,y:-1},
{a:2,x:-1,y:0},
{a:5,x:-1,y:1},
{a:2,x:-1,y:0},
{a:1,x:0,y:-1},
{a:2,x:0,y:-2},
{a:1,x:0,y:0}

]

orange gold
07-07-2007, 06:36 AM
i think it would be cool if var times of change was equivalent to xmouse and y mouse

mattkenefick
07-07-2007, 01:21 PM
i think it would be cool if var times of change was equivalent to xmouse and y mouse

Well the idea isn't to have it follow the mouse. It's to make an animation for an intro, or a rollover or something.

My example was pretty crude, but its just that it can have some 3d feel to it, have the size and alpha of the object change to simulate depth and have it curve etc..

Most of those line animation things you see are videos imported, but I'd like to make a realtime vector animation class that simulates that.

orange gold
07-07-2007, 04:58 PM
i meant it starts out moving the boxes to the right if your mouse is on the left it will curve around to the left then if you move it up it will curve up and start moving that way and if it gets to your mouse and you dont move the mouse it will curve around and come back to the mouse untill moved