PDA

View Full Version : More fulid mouse movement.


victorysshadow
03-06-2003, 04:44 PM
Is there a way to make mouse movement more fluid? Check the following attached example. (click in the gray space and move around... then press play when the time is up) When you move to extremes it gets choppy.

Is there a way around this?

Thanks.

vshadow

annexion
03-07-2003, 12:45 AM
Increase your frame rate.

The array is recorded on enterFrames, meaning if your fps is set to 30, then you will have 30 mouse coordinates per second. 60 for both x and y. So, the only way to make it more fluid, and record more positions is to increase the frame rate.

Good luck.

JLM
03-12-2003, 01:03 PM
setInterval allows you to have a slow frame rate for background graphics and fast movement for mc's following the mouse if thats what you are doing?

victorysshadow
03-12-2003, 04:09 PM
How exactly would you use setInterval in the following code? (also see attached)

var numfades=5;
var fadeRate=15;
var pastx=_xmouse;
var pasty=_ymouse;
var selfmc=this;
var linecolor="0xFFFFFF";
stop();

selfmc.onEnterFrame= function(){traceMe(a1)};
function traceMe(which)
{
ron.gotoAndStop(_currentframe);
numfades++;
selfmc.createEmptyMovieClip("a" + numfades, numfades);
with(selfmc["a"+numfades])
{
lineStyle(6,lineColor,100);
moveTo(rec_ball._x,rec_ball._y);
lineTo(pastx,pasty);
}
pastx=rec_ball._x;
pasty=rec_ball._y;
for(x=numfades; x>numfades-12 && x>1; x--)
{
selfmc["a"+x]._alpha-=fadeRate;
if(selfmc["a"+x]<1)
{
selfmc["a"+x].clear();
selfmc["a"+x].removeMovieClip();
}
}
}

function initi() {
movingX = [];
movingY = [];
i = 0;
rec_ball._x = _xmouse;
rec_ball._y = _ymouse;
}

rec_btn.onRelease = function() {
instructs._visible = false;
Mouse.hide();
rec_ball.onEnterFrame = function() {
//adjust THE number in the following line for the amount of time recording takes place--in frames, ie 120 @ 24 fr/sec = 5 sec
if (i<200) {
movingX[i] = _xmouse;
movingY[i] = _ymouse;
} else {
this.onEnterFrame = null;
i = 0;
Mouse.show();
gotoAndStop(2);
}
i++;
this._x = _xmouse;
this._y = _ymouse;
};
};

JLM
03-13-2003, 12:35 AM
Well did not get it working that much faster because I started using curves, the back button needs sorting out. It seem difficult to get to grips with someone elses work. Should have kept quiet, but was at work and did not see the source code!

hope it helps JLM



MCP=MovieClip.prototype;
MCP.moveToOld=MCP.moveTo;
MCP.moveTo = function(x,y,z) {with (this){
moveToOld(x,y);
_xpen=_xpenStart=x;_ypen=_ypenStart=y;
}};
//penner function prob change slightly
MCP.curveThru = function (tx,ty,ex,ey){
var cx=(2*tx)-.5*(_xpen+ex);
var cy=(2*ty)-.5*(_ypen+ey);
this.moveTo(_xpen,_ypen);
this.curveTo(cx,cy,ex,ey);
_xpen=x;_ypen=y;
};
_xpen=_ypen=_xpenStart=_ypenStart=0;
ASSetPropFlags(MCP,null,1);

var numfades=5;
var fadeRate=10;
var pastx=_xmouse;
var pasty=_ymouse;
var selfmc=this;
var linecolor="0xFFFFFF";
stop();
function initi() {
movingX = [];
movingY = [];
i = 0;
rec_ball._x = _xmouse;
rec_ball._y = _ymouse;
};
initi();
myinterval=1;
runtime=300;
fade=24;

rec_btn.onRelease = function() {
instructs._visible = false;
Mouse.hide();
doRecord=setInterval(record,myinterval);
};
record=function(){
if (i<runtime) {
traceMe()
movingX[i] = _xmouse;
movingY[i] = _ymouse;
} else {
i = 0;
Mouse.show();
gotoAndStop(2);
clearInterval(doRecord);
}
i++;
rec_ball._x = _xmouse;
rec_ball._y = _ymouse;
updateAfterEvent();
};
playRecord=function(){
if (i<runtime) {
rec_ball._x = movingX[i];
rec_ball._y = movingY[i];
traceMe()
} else {
i = 0;
gotoAndStop(3);
clearInterval(doPlay);
}
i++;
updateAfterEvent();
};

//selfmc.onEnterFrame= function(){setInterval(traceMe,myInterval)};
function traceMe(){
gotoAndStop(_currentframe);
numfades++;
selfmc.createEmptyMovieClip("a" + numfades, numfades);
with(selfmc["a"+numfades]){
moveTo(rec_ball._x,rec_ball._y);
lineStyle(6,lineColor,100);
if (math.round(i/2)==i/2) {
curveThru(pastx,pasty,pastx2,pasty2);
}// else { lineto(rec_ball._x,rec_ball._y);};
for(x=numfades; x>numfades-fade && x>1; x--){
selfmc["a"+x]._alpha-=fadeRate;
if(selfmc["a"+x]<1){
selfmc["a"+x].clear();
selfmc["a"+x].removeMovieClip();
}
}
}
pastx2=pastx;
pasty2=pasty;
pastx=rec_ball._x;
pasty=rec_ball._y;
//updateAfterEvent();
};
backbutton=function(){
//needs some tidying
i = 0;
gotoAndStop(1);
};
//for reference////////////////
/*ply_btn.onRelease = function() {
doPlay=setInterval(playRecord,myInterval);
};
back_btn.onRelease = function() {
backbutton();
}*/



p.s. interesting code fun to play with.

no response?, would it help if I posted a link to the modified file?

victorysshadow
03-13-2003, 02:19 PM
Thanks JLM!

Yeah, I think it would help to post the modified file... if you could do that that would be great!

thanks

vshadow

JLM
03-13-2003, 09:33 PM
copy and paste link
www27.brinkster.com/jlm/newrecorder3.FLA