sr2449
80 posts
|
It’s suppose to cause the object the the script is in to move to the top left corner and then back, instead it just goes to the top left corner. I haven’t really used AS in a few years, so I am rusty, anybody see my error?
onClipEvent(load)
{
rotatespeed = 3;
timer = 0;
movedirection = 1;
movebacktime = 100;
movespeed = 10
}
onClipEvent(enterFrame)
{
_rotation += rotatespeed;
timer += 1;
if(movedirection = 1)
{
_x -= movespeed;
_y -= movespeed;
}
else
{
_x += movespeed;
_y += movespeed;
}
if(timer >= movebacktime)
{
if(movedirection = 1)
{
movedirection = 2;
}
else
{
movedirection = 1;
}
timer = 0;
}
}
|
|
|
Shake_N_Baker
53 posts
|
Your if statements are wrong. A single equal sign means assign or set, so if(movedirection = 1) simply sets the movedirection to 1 and continues on as if it were if(true) written there. You want to use two equal signs to compare the value of movedirection and 1 so if(movedirection == 1) would be correct
|
|
|
Khronosis
130 posts
|
Originally posted by sr2449:
if(movedirection = 1)
“=” is for assigning values.
“==” is for comparing values.
|
|
|
Draco18s
6860 posts
|
You realize that you’re telling it to move for 100 frames (in each direction), and each frame to move 10 pixels, right? Which means that it’s entire motion is 1000 pixels.
|
|
|
JWBSoftware
106 posts
|
What they wrote about ‘=’ and ‘==’. If you’re using the Flex compiler it will warn you of such things as they’re easy to miss. Or get in the habit of reversing such clauses, i.e. write them like this:
if (1 == movedirection)
Then if you leave out one of the equals signs you have something that’s impossible so which won’t compile.
|
|
|
TJEisemann
25 posts
|
Originally posted by JWBSoftware:
if (1 == movedirection)
If brown is the cow.
|
|
|
Aesica
952 posts
|
Originally posted by TJEisemann:
If brown is the cow.
That’s not how it works. It’d be more like:
if (brown == cow || cow == brown) would always return false, no matter the order because a cow is not a color and a color is not a cow. You’re thinking of:
if (brown == cow.color) which is the same as if (cow.color == brown)
|
|
|
TJEisemann
25 posts
|
Just commenting on the illogical nature of the logic “if (constant == variable)”.
If the cow is brown.
If brown is the cow.
|
|
|
Ace_Blue
1093 posts
|
if (debate.point == null) closeThread(); ?
|
|
|
Draco18s
6860 posts
|
Originally posted by TJEisemann:
Just commenting on the illogical nature of the logic “if (constant == variable)”.
If the cow is brown.
If brown is the cow.
“If brown the cow is” would be more grammatically correct. Brown can’t be a cow.
|
|
|
BigJM
468 posts
|
Originally posted by Draco18s:
Originally posted by TJEisemann:
Just commenting on the illogical nature of the logic “if (constant == variable)”.
If the cow is brown.
If brown is the cow.
“If brown the cow is” would be more grammatically correct. Brown can’t be a cow.
You think that’s more grammatically correct? :P
|
|
|
Aesica
952 posts
|
Originally posted by BigJM:
You think that’s more grammatically correct? :P
More grammatically correct, it is.

(More logically correct, anyway)
|
|
|
TJEisemann
25 posts
|
Originally posted by Draco18s:
“If brown the cow is” would be more grammatically correct. Brown can’t be a cow.
Your assuming my cow !== “brown”
|
|
|
JWBSoftware
106 posts
|
You don’t have to invoke a green and pointy-eared warrior to justify such an ordering. E.g, considering a lottery win one might say:
“If the winner is me I will give up work”
or
“If I am the winner I will give up work”
Of course “If the winner is I” is more grammatically correct, though people look at you funny if you speak like that. And most people would just say “If I win [the lottery] I will give up work”.
|
|
|
feartehstickman
521 posts
|
Originally posted by TJEisemann:
Originally posted by Draco18s:
“If brown the cow is” would be more grammatically correct. Brown can’t be a cow.
Your assuming my cow !== “brown”
I believe it’s !=
|