Hey thanks Mike,

I've managed to do it rather simply with this in case anyone is interested:




// create laser point
var laser = {x:0, y:0, vx:10, vy:10, steps:[], count:0};

onEnterFrame = function()
{
   // bounce off the walls
   if (laser.x > 400)
   {
       laser.vx *=-1;
   }
   else if (laser.x < 0)
   {
       laser.vx *=-1;
   }
   if (laser.y > 200)
   {
       laser.vy *=-1;
   }
   else if (laser.y < 0)
   {
       laser.vy *=-1;
   }
// update current point
   laser.x+=laser.vx;
   laser.y+=laser.vy;

   // if laser doesn't have a complete history of steps
   if (laser.steps.length < 10)
   {
       // add a step
       laser.steps[laser.count] = {x:laser.x, y:laser.y};
// update count
       laser.count++;
   }
   else
   {
       // remove the oldest step
       laser.steps[0] = undefined;
// loop through all steps
       for (var i=1;i<laser.steps.length;i++)
       {
           // shuffle steps back by one position
           laser.steps[(i-1)] = laser.steps[i];
       }
       // add the current position to the top of the stack
       laser.steps[10] = {x:laser.x, y:laser.y};
   }
// clear drawings from last frame
   _root.clear();
// choose base colour for laser
   _root.lineStyle(8, 0xFF0000, 80);
// move to laser head point
   _root.moveTo(laser.x, laser.y);
// loop through previous steps drawing back to oldest recorded step
   for (var i=laser.steps.length-1;i>0;i--)
   {
_root.lineTo(laser.steps[i].x, laser.steps[i].y); } // change to medium colour
   _root.lineStyle(7, 0xFF0099, 100);
// move back to laser head point
   _root.moveTo(laser.x, laser.y);
// loop through previous steps drawing back to oldest recorded step
   for (var i=laser.steps.length-1;i>0;i--)
   {
_root.lineTo(laser.steps[i].x, laser.steps[i].y); } // change to topmost colour
   _root.lineStyle(4, 0xFFFFFF, 100);
// move back to laser head point
   _root.moveTo(laser.x, laser.y);
// loop through previous steps drawing back to the oldest recorded step
   for (var i=laser.steps.length-1;i>0;i--)
   {
_root.lineTo(laser.steps[i].x, laser.steps[i].y); } }





Mike Mountain wrote:

Well I've never made one before - but I'd store an array of the gun,
mirrors, and goals x,y and rotation properties and crawl through them to
draw the line...something like:

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to