http://www.strille.net/works/misc/followScriptedPath/followPath.html
and Modified to as type....
thanks fot the author.....
Smooth_path.as
class Smooth_path {
public var pathDetail:Number = .05;
public var drawPath:Boolean = true;
public function Smooth_path(myPath:MovieClip, line_data_arr:Array) {
trace("sdghafasjdgf"+[myPath, line_data_arr]);
// how smooth the path is, should not be much lower than 0.05, and must be > 0
//var myPath:MovieClip = _root.createEmptyMovieClip("myPath", _root.getNextHighestDepth());
Path(myPath);
// create a new path
for (var i:Number = 0; i<=line_data_arr.length-1; i++) { trace([line_data_arr[i].x, line_data_arr[i].y]); addPoint(myPath, line_data_arr[i].x, line_data_arr[i].y); } calcPath(myPath, pathDetail, drawPath); } private function Path(myPath:MovieClip) { myPath.x = []; myPath.y = []; myPath.numOfPoints = 0; myPath.subPointDis = null; myPath.subPointX = null; myPath.subPointY = null; myPath.subPointXl = null; myPath.subPointYl = null; myPath.totalDistance = 0; } private function addPoint(myPath:MovieClip, x, y) { myPath.x.push(x); myPath.y.push(y); myPath.numOfPoints++; } private function createContainers(myPath:MovieClip) { if (myPath.pathContainer == undefined) { if (_root["pathMC"] == undefined) { _root.createEmptyMovieClip("pathMC", _root.getNextHighestDepth()); } _root["pathMC"].createEmptyMovieClip("lineMC", _root.pathMC.getNextHighestDepth()); _root["pathMC"].createEmptyMovieClip("anchorMC", _root.pathMC.getNextHighestDepth()); myPath.pathContainer = _root["pathMC"].lineMC; myPath.anchorContainer = _root["pathMC"].anchorMC; } } private function calcPath(myPath:MovieClip, pathStepSize, drPath) { if (drPath) { trace(typeof (myPath)); createContainers(myPath); myPath.pathContainer.clear(); myPath.pathContainer.lineStyle(0, 0xcccccc, 100); //myPath.pathContainer.moveTo(myPath.x[0], myPath.y[0]); myPath.pathContainer._x = myPath.x[0]; myPath.pathContainer._y = myPath.y[0]; } else if (myPath.pathContainer) { myPath.pathContainer.removeMovieClip(); myPath.anchorContainer.removeMovieClip(); delete myPath.pathContainer; } myPath.subPointDis = [0]; myPath.subPointX = [myPath.x[0]]; myPath.subPointY = [myPath.y[0]]; myPath.subPointDisl = []; myPath.subPointXl = []; myPath.subPointYl = []; for (var t = -1.0; t
type the following in first frame...
var line_data_arr:Array = new Array();
line_data_arr.push({x:54.1666666666667, y:500});
line_data_arr.push({x:108.333333333333, y:0});
line_data_arr.push({x:162.5, y:307.055555555556});
line_data_arr.push({x:216.666666666667, y:483.333333333333});
line_data_arr.push({x:270.833333333333, y:487});
line_data_arr.push({x:325, y:431.444444444444});
line_data_arr.push({x:379.166666666667, y:472.222222222222});
var myPath:MovieClip = _root.createEmptyMovieClip("myPath", _root.getNextHighestDepth());
var pp:Smooth_path = new Smooth_path(myPath, line_data_arr);
---------------------------
test flash ..........
Source Files
0 comments:
Post a Comment