PDA

View Full Version : creating a line that appears from 0 to x


ffflash
09-19-2005, 10:40 PM
Hi,
Iīm trying to make that a line appears from the 0 to the length I want, but not only this, I also want that the line follows the shape that I want, for example a rectangle, a polyline, etc...
I saw this effect in www.2advanced.com.
Iīm learning AS, and at the moment I only get to this code:

Keyframe 01:
i = 1 //x first point
k = 400 //x end point
d = 1

Key frame 02:
_root.createEmptyMovieClip("line" , 1);
with (line) {
lineStyle(2,0x000000,70);
moveTo(i,0);
lineTo(i+d,0);
updateAfterEvent();
}

Keyframe03:
d = (d) + 20;
if ( (d) >= (k-i) ) {
gotoAndStop(4);
} else {
gotoAndPlay(2);
updateAfterEvent();
}


Thank you for your help

Xeef
09-20-2005, 12:06 AM
Hmmm

no idea what you want :(

but try this :


X = 100;
Y = 200;
lineStyle(1, 0, 100);
moveTo(X, Y);
S = 0;
MovementArray = [[50, 0, -1], [25, 1, -1], [25, 1, 1], [50, 0, 1], [50, -1, 0], [50, 1, -1], [50, -1, 0], [50, 1, 1]];
onEnterFrame = function () {
if (C == CC) {
delete vX;
delete vY;
delete CC;
}
if (vX == undefined) {
vX = MovementArray[S][1];
}
if (vY == undefined) {
vY = MovementArray[S][2];
}
if (CC == undefined) {
C = 0;
CC = MovementArray[S][0];
S++;
}
X += vX;
Y += vY;
C++;
lineTo(X, Y);
};

ffflash
09-20-2005, 08:36 AM
Thank you very much.
Thatīs not exactly what I want, but itīs very interesting, and I think I can do something good. Itīs much better than I could get.
Only I ask if there is any way to make it goes faster (without going up the fps).

Thank you very much at all.

Xeef
09-20-2005, 09:19 AM
[50, 0, -1], ....

1. is how many steps are made
2. X direction
3. y direction

if you higher X or Y it will go faster but also draw bigger
so higher X & Y by 2 and divide steps by 2
eg.
[25, 0, -2], ...

shoud give the same result in 2X speed

ffflash
09-20-2005, 09:35 AM
Thank you very much. Now I understand the matrix much better, :))
Iīm sorry not to know so many thing, so that thanks.

sandeep_cdac200
09-20-2005, 09:55 AM
hi i have seen ur code and implement it. bt i dont understand how it works. can you please explain its working?

Xeef
09-20-2005, 11:30 AM
"C" is incremented on each step
if "C" is equal to "CC"
we delete all variables which mean they become "undefined"
and set "S" the array pointer one higher
if the variables are undefined (which is the case at the very begining and after C=CC)
we load the coresponding data from the array


vX --> the movement vector on X axis
vY --> the movement vector on Y axis
S --> array pointer
C curent step (is set back to "0" on the next vector)
CC --> how many steps to do whit the curent vector
X & Y --> wher the drawing begins

sorry not good at describing