FORUMS: list search recent posts

1084: Syntax error: expecting identifier before leftbracket/expecting rightbrace before rightbracket.

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Michael Mwangi
1084: Syntax error: expecting identifier before leftbracket/expecting rightbrace before rightbracket.
on Sep 13, 2014 at 1:14:36 pm

Hello guys! I'm getting these two errors in my code. Kindly assist

var arrPosition: Array = new Array(4);
arrPosition[0] = char1_mc.x;
arrPosition[1] = char2_mc.x;
arrPosition[2] = char3_mc.x;
arrPosition[3] = char4_mc.x;

var lowest: int = arrPosition[0];
var pos: int = 0;

for (var i in arrPosition)
{
if (arrPosition[i] < lowest)
{
lowest = arrPosition[i];
pos = i;
}

}

var chk: int = pos + 1;
var a: int;

for (a = 1; a <= 4; a++)
{
if (a == chk)
{
Error1 line: this.["char" + a + "_mc"].gotoAndPlay("cheering");
}
else
{
Error2 line: this.["char" + a + "_mc"].gotoAndPlay("crying");
}
}


Return to posts index

Sam Mattern
Re: 1084: Syntax error: expecting identifier before leftbracket/expecting rightbrace before rightbracket.
on Sep 15, 2014 at 3:41:16 pm

When you are trying to use dynamic variable access, you don't put a period before the left bracket. It should be:


this["char" + a + "_mc"].gotoAndPlay("cheering");
this["char" + a + "_mc"].gotoAndPlay("crying");


-Sam


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]