
June 15th, 2005
01:19 AM
Flash designer, learner.
Status: Offline!
Creating & moving a line using actionscripting?
I've went through forum posts and found a few threads on creating a line. What I'd like to do is create a line (a curve, not a straight line) and control both points of the line using actionscript tweening. I haven't found very much on this here in forums. Would anyone happen to know a good site that would have something of this subject i'd be able to read up on? Or just give me a few pointers or lines of code to point me in the right direction?
I'm actually trying to make a sorta stick-man walking, but I wan't it to look a little more man than stick.
Thanks,
aok

June 16th, 2005
12:13 AM
Neverside Newbie
Status: Offline!
You can use code like this to draw a curved line, with the Flash Drawing API.
// Create the MC
var cv:MovieClip = _root.createEmptyMovieClip("cv", 1);
// Set the linestyle
cv.lineStyle(2, 0x000000, 100);
// Position our virtual 'cursor'
cv.moveTo(20, 20);
// Draw a curve, curveTo(controlpointX, controlpointY, pointx, pointY)
cv.curveTo(100, 500, 200, 200);
As for animating it, you'd have to have an some sort of onEnterFrame loop constantly redrawing your line..something like this maybe...
// Create the MC
var cv:MovieClip = _root.createEmptyMovieClip("cv", 1);
// Setup Some Vars
var x:Number = 200;
var y:Number = 500;
// Create a function to draw our curve
function drawCurve(ctrlX:Number, ctrlY:Number):Void {
// Set the linestyle
cv.lineStyle(2, 0x000000, 100);
// Position our virtual 'cursor'
cv.moveTo(20, 20);
// Draw a curve, curveTo(controlpointX, controlpointY, pointx, pointY)
cv.curveTo(ctrlX, ctrlY, 200, 200);
}
cv.onEnterFrame = function() {
// Comment out the following line, and the line won't dissapear when anohter is drawn.
cv.clear();
_root.drawCurve(_root.x++, _root.y++);
};
To tell you the truth, it wouldn't be very easy >_<
Maybe you should just animate it the good ol' way 
___________________

Last edited by hamstu, June 16th, 2005 12:14 AM (Edited 2 times)

June 25th, 2005
09:04 PM
Vivo para el sanwich!
Status: Offline!
Doing an actual animation in AS would be extremely hard and take a hundered times longer than if you were to animate it by hand.
___________________
I have flash in the pants!