// lineslug.as: func def fr line05 // rev 06 on mon 26 may 2003 /////////////////////////////////////////// // now define function slugLine -- drawing procedure with 10 params: // MC path: where // slug path" what // pen: thickness in pixels // color as RGB hex // number of segments to draw: numSteps // init screen coords: (eye0, jay0) // final screen coords: (eye1, jay1) // delay between steps in msecs: delay function slugLine(where, what, thickness, color, numSteps, eye0, jay0, eye1, jay1, delay) { // set up the pen (thickness, color, alpha=100) where.lineStyle(thickness, color, 100); // init values eye = eye0; jay = jay0; stepcount = 0; // set increments Deye = (eye1 - eye0)/numSteps; Djay = (jay1 - jay0)/numSteps; // move pen to start point where.moveTo(eye, jay); function drawSteps (){ eye = Math.round(eye + Deye); // increment eye, jay jay = Math.round(jay + Djay); stepcount++; ////trace("eye = "+eye); ////trace("jay = "+jay); ////trace("stepcount = "+stepcount); where.LineTo(eye, jay); what._x = eye; what._y = jay; // now break iter loop if stepcount reaches limit if (stepcount == numSteps){ clearInterval(intervalID); stepcount = 0; } } // now alternate sleep "delay" milliseconds and draw a step, // cf moock, p. 757 var intervalID = setInterval(drawSteps, delay); } // end of function slugLine /////////////////////////////////////////////