1

I'm a newbie with flash, what I'm trying to do is make the background scroll with my mouse...but this is giving me a syntax error...where is the error coming from?

var movieWidth:Number = stage.stageWidth;

menuWidth = nav1.width;

nav2.x = nav1.x + menuWidth;

addEventListener("enterFrame",frame_handler);

function frame_handler(e:Event) {
var a:Number = mouseX;
var b:Number = movieWidth/2;
var c:Number = 20;
var pos:Number= 0-((a-b)/20);

nav1.x += pos;
nav2.x += pos;

if (nav1.x >= 0 && nav1.x <= menuWidth)
{ nav2.x = nav1.x – menuWidth }
else if (nav1.x <= movieWidthmenuWidth)
{ nav2.x = nav1.x + menuWidth }

if (nav2.x <=movieWidth-menuWidth) 
{ nav1.x = nav2.x + menuWidth } 
else if (nav2.x>=0) 
{ nav1.x = nav2.x- menuWidth }

}
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
James Gu
  • 1,382
  • 4
  • 26
  • 39
  • Are you getting the error at compile time, or is it at run time? What does the error message say? Can you highlight the specific line? We can try to explain the error once we've seen it. – Manish Feb 29 '12 at 15:53

2 Answers2

1

Note this statement

{ nav2.x = nav1.x – menuWidth }

I think that your minus character is wrong one in this statement

wrong one (ASCII 8211)  –

correct one (ASCII 45) -

Please replace. Check other statements also.

See this : http://www.cs.sfu.ca/~ggbaker/reference/characters/

Diode
  • 24,570
  • 8
  • 40
  • 51
0

Is menuWidth ever declared? same for nav1 and nav2 - what is it?

Besides, you would be on the safe side, if you put a semicolon after a statement. It is not mandatory as per the compiler rules, but it may put you in a confusing situation, where you would misinterpret the code.

As an aside: unary - operator does the same as binary - operator when the first operand is 0. That is the expression:

0 - x

is equivalent to:

-x