At 6/14/09 03:04 PM, Yambanshee wrote:
problem
Place on the frame
presuming:
car registration point is in the middle of the car.
car instance is "car"
var w:Number = car._width/2;
var h:Number = car._height/2;
var i:Number = 1;
var Lines:Array = new Array();
onEnterFrame = function () {
_root.createEmptyMovieClip("TR"+i, i);
//creates a new MC
Lines.push(_root["TR"+i]);
//adds the MC to the array
_root["TR"+i].lineStyle(2, 0x000000, 100);
//sets the style of the line (thickness, colour, alpha)
_root["TR"+i].moveTo(_root.car._x+Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y-Math.cos(Math.PI/180*_root.car._rotation)*h);
//moves the line to the top right of the car
i++;
//increases i
_root.createEmptyMovieClip("TL"+i, i);
//creates a new MC
Lines.push(_root["TL"+i]);
//adds the MC to the array
_root["TL"+i].lineStyle(2, 0x000000, 100);
//sets the style of the line (thickness, colour, alpha)
_root["TL"+i].moveTo(_root.car._x-Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y-Math.cos(Math.PI/180*_root.car._rotation)*h);
//moves the line to the top left of the car
i++;
//increases i
_root.createEmptyMovieClip("BL"+i, i);
//creates a new MC
Lines.push(_root["BL"+i]);
//adds the MC to the array
_root["BL"+i].lineStyle(2, 0x000000, 100);
//sets the style of the line (thickness, colour, alpha)
_root["BL"+i].moveTo(_root.car._x-Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y+Math.cos(Math.PI/180*_root.car._rotation)*h);
//moves the line to the bottom left of the car
i++;
//increases i
_root.createEmptyMovieClip("BR"+i, i);
//creates a new MC
Lines.push(_root["BR"+i]);
//adds the MC to the array
_root["BR"+i].lineStyle(2, 0x000000, 100);
//sets the style of the line (thickness, colour, alpha)
_root["BR"+i].moveTo(_root.car._x+Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y+Math.cos(Math.PI/180*_root.car._rotation)*h);
//moves the line to the bottom right of the car
i++;
//increases i
_root.car._x += Math.sin(Math.PI/180*_root.car._rotation)*5;
//x movement
_root.car._y -= Math.cos(Math.PI/180*_root.car._rotation)*5;
//y movement
_root["TR"+i].lineTo(_root.car._x+Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y-Math.cos(Math.PI/180*_root.car._rotation)*h);
//draws line
_root["TL"+i].lineTo(_root.car._x-Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y-Math.cos(Math.PI/180*_root.car._rotation)*h);
//same
_root["BL"+i].lineTo(_root.car._x-Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y+Math.cos(Math.PI/180*_root.car._rotation)*h);
//same
_root["BR"+i].lineTo(_root.car._x+Math.sin(Math.PI/180*_root.car._rotation)*w, _root.car._y+Math.cos(Math.PI/180*_root.car._rotation)*h);
//same
//for removing lines
for(L=0;L<_root.Lines.length;L++){
_root.Lines[L]._alpha-=5;//decreases the alpha by 5
if(_root.Lines[L]._alpha <=0){
_root.Lines[L].removeMovieClip();//removes movie clip
_root.Lines.splice(L, 1);//removes from array
}
}
};
that SHOULD work, i havn't tested it but it doesn't have any errors...
i've explained bits of it i'll go into more detail if needed