Floody
10-22-2008, 03:08 PM
Hello,
I've got some script that makes a little man movieclip run after the cursor (in fact I downloaded it from this website!)
However, I'm working in Actionscript 3, which I knows has several differences from as2 and some syntax differences. For one, I think I'm right in saying I can't put script on an object (in this case the movieclip of the little man), so I need to put in on a frame and have a listener waiting to act on the clip. So I've got some code below, but I get a lot of error messages that read:
1083: Syntax error: rightparen is unexpected.
1084: Syntax error: expecting semicolon before leftbrace.
1083: Syntax error: else is unexpected.
Any ideas what I'm doing wrong/ how I can solve this problem?
:-)
human_mc.addEventListener(MouseEvent.MOVE, manmove);
function manmove(event:MouseEvent):void {
xM = _root._xmouse;
yM = _root._ymouse;
b = (yM-_root.human_mc._y)/(xM-_root.human_mc._x);
a = 57.3*Math.atan(b);
if (xM>=_root.human_mc._x) {
if ((-90<=a) and (a<=-67)) {
_root.fr = 1;
}
if ((-67<a) and (a<=-22)) {
_root.fr = 3;
}
if ((-22<a) and (a<=22)) {
_root.fr = 5;
}
if ((22<a) and (a<=67)) {
_root.fr = 7;
}
if ((67<a) and (a<=90)) {
_root.fr = 9;
}
}
else {
if ((-90<=a) and (a<=-67)) {
_root.fr = 9;
}
if ((-67<a) and (a<=-22)) {
_root.fr = 11;
}
if ((-22<a) and (a<=22)) {
_root.fr = 13;
}
if ((22<a) and (a<=67)) {
_root.fr = 15;
}
if ((67<a) and (a<=90)) {
_root.fr = 1;
}
}
}
I've got some script that makes a little man movieclip run after the cursor (in fact I downloaded it from this website!)
However, I'm working in Actionscript 3, which I knows has several differences from as2 and some syntax differences. For one, I think I'm right in saying I can't put script on an object (in this case the movieclip of the little man), so I need to put in on a frame and have a listener waiting to act on the clip. So I've got some code below, but I get a lot of error messages that read:
1083: Syntax error: rightparen is unexpected.
1084: Syntax error: expecting semicolon before leftbrace.
1083: Syntax error: else is unexpected.
Any ideas what I'm doing wrong/ how I can solve this problem?
:-)
human_mc.addEventListener(MouseEvent.MOVE, manmove);
function manmove(event:MouseEvent):void {
xM = _root._xmouse;
yM = _root._ymouse;
b = (yM-_root.human_mc._y)/(xM-_root.human_mc._x);
a = 57.3*Math.atan(b);
if (xM>=_root.human_mc._x) {
if ((-90<=a) and (a<=-67)) {
_root.fr = 1;
}
if ((-67<a) and (a<=-22)) {
_root.fr = 3;
}
if ((-22<a) and (a<=22)) {
_root.fr = 5;
}
if ((22<a) and (a<=67)) {
_root.fr = 7;
}
if ((67<a) and (a<=90)) {
_root.fr = 9;
}
}
else {
if ((-90<=a) and (a<=-67)) {
_root.fr = 9;
}
if ((-67<a) and (a<=-22)) {
_root.fr = 11;
}
if ((-22<a) and (a<=22)) {
_root.fr = 13;
}
if ((22<a) and (a<=67)) {
_root.fr = 15;
}
if ((67<a) and (a<=90)) {
_root.fr = 1;
}
}
}