Groups | Blog | Home
all groups > flash actionscript > february 2006 >

flash actionscript : Converting Actionscript


Ross111
2/4/2006 9:10:29 PM
Hello,

I got an actionscipt from a tutorial recently... its really cool so i was
going to edit it and use it in one of my movies.... the problem is that it was
made for flash player 6 and actionscript 1.0, and i need it to work for flash
player 8 and actionscript 2.0 but when i went to publish settings and changed
it to Flash Player 8 the actionscript didn't work anymore, so is there anyway
to take the actionscript and update it so it will work for flash player 8...
plase help if any of that made sense...
NSurveyor
2/4/2006 9:29:07 PM
Make sure the variables have been initialized before your increment/decrement
them. For example, you could once do: counter++; but since mx 2004, you need to
have: counter = 0; and then you can use counter++; The only other thing that
comes to mind is capitalization, counter is not equal to CouNtER - I don't
remember if case sensitivity is a flash player thing or ActionScript 2.0 thing.

It would be best to just post the code so someone here can show you why that
specific code isn't working.
Ross111
2/4/2006 9:35:19 PM
Didn't really get what you said there.... So.... Heres The Code...

onClipEvent (load) {
friction = 0.900000;
accelfactor = 1000;
mousex = ;
mousey = ;
check = 0;
n = 1;
bt = 0;
}
onClipEvent (enterFrame) {
for (i=5; i>=1; i--) {
mousex = mousex;
mousey = mousey;
}
mousex = _xmouse;
mousey = _ymouse;
if (check != 1) {
xsaL = cursolL._x-mousex+10;
ysaL = cursolL._y-mousey;
xsaL>0 ? (xaccelL=-xsaL*xsaL/accelfactor, xaccelL=-xsaL*xsaL/accelfactor) :
(xaccelL=xsaL*xsaL/accelfactor);
ysaL>0 ? (yaccelL=-ysaL*ysaL/accelfactor, yaccelL=-ysaL*ysaL/accelfactor) :
(yaccelL=ysaL*ysaL/accelfactor);
xspeedL = (xspeedL+xaccelL)*friction;
yspeedL = (yspeedL+yaccelL)*friction;
cursolL._x = cursolL._x+xspeedL;
cursolL._y = cursolL._y+yspeedL;
xsa = cursolR._x-mousex-10;
ysa = cursolR._y-mousey;
xsa>0 ? (xaccel=-xsa*xsa/accelfactor, xaccel=-xsa*xsa/accelfactor) :
(xaccel=xsa*xsa/accelfactor);
ysa>0 ? (yaccel=-ysa*ysa/accelfactor, yaccel=-ysa*ysa/accelfactor) :
(yaccel=ysa*ysa/accelfactor);
xspeed = (xspeed+xaccel)*friction;
yspeed = (yspeed+yaccel)*friction;
cursolR._x = cursolR._x+xspeed;
cursolR._y = cursolR._y+yspeed;
} else {
if (bt != 1) {
xmove1 = (cursolL._x-x1+4)/5;
ymove1 = (cursolL._y-y)/5;
xmove2 = (cursolR._x-x2)/5;
ymove2 = (cursolR._y-y)/5;
bt = 1;
n = 1;
}
if (n<=5) {
cursolL._x = cursolL._x-xmove1;
cursolL._y = cursolL._y-ymove1;
cursolR._x = cursolR._x-xmove2;
cursolR._y = cursolR._y-ymove2;
n++;
}
}
}

Thanks For Your Help !
NSurveyor
2/4/2006 10:09:16 PM
xspeed, yspeed, xspeedL, and yspeedL have never been initialized. Just stick
the following lines into the onClipEvent(load)

xspeed = 0;
yspeed = 0;
xspeedL = 0;
yspeedL = 0;

I also made the code a little up to date.. Just place the cursolR and cursolL
on the stage, and place this script on the Frame they both reside on:

friction = 0.900000;
accelfactor = 1000;
mousex = [320, 320, 320, 320, 320];
mousey = [180, 180, 180, 180, 180];
check = 0;
n = 1;
bt = 0;
xspeed = 0;
yspeed = 0;
xspeedL = 0;
yspeedL = 0;
onEnterFrame = function () {
mousex.unshift(_xmouse);
mousey.unshift(_ymouse);
mousex.splice(6);
mousey.splice(6);
if (check != 1) {
xsaL = cursolL._x-mousex[0]+10;
ysaL = cursolL._y-mousey[0];
xsaL>0 ? (xaccelL=-xsaL*xsaL/accelfactor) : (xaccelL=xsaL*xsaL/accelfactor);
ysaL>0 ? (yaccelL=-ysaL*ysaL/accelfactor) : (yaccelL=ysaL*ysaL/accelfactor);
xspeedL = (xspeedL+xaccelL)*friction;
yspeedL = (yspeedL+yaccelL)*friction;
cursolL._x = cursolL._x+xspeedL;
cursolL._y = cursolL._y+yspeedL;
xsa = cursolR._x-mousex[5]-10;
ysa = cursolR._y-mousey[5];
xsa>0 ? (xaccel=-xsa*xsa/accelfactor) : (xaccel=xsa*xsa/accelfactor);
ysa>0 ? (yaccel=-ysa*ysa/accelfactor) : (yaccel=ysa*ysa/accelfactor);
xspeed = (xspeed+xaccel)*friction;
yspeed = (yspeed+yaccel)*friction;
cursolR._x = cursolR._x+xspeed;
cursolR._y = cursolR._y+yspeed;
} else {
if (bt != 1) {
xmove1 = (cursolL._x-x1+4)/5;
ymove1 = (cursolL._y-y)/5;
xmove2 = (cursolR._x-x2)/5;
ymove2 = (cursolR._y-y)/5;
bt = 1;
n = 1;
}
if (n<=5) {
cursolL._x = cursolL._x-xmove1;
cursolL._y = cursolL._y-ymove1;
cursolR._x = cursolR._x-xmove2;
cursolR._y = cursolR._y-ymove2;
n++;
}
}
};
Ross111
2/4/2006 10:15:45 PM
NSurveyor
2/4/2006 10:32:34 PM
AddThis Social Bookmark Button