Unexpected symbol near '[', animation problem.

Hi!

I’m trying to move an object from left and to the right and I’m gonna build 3 “lanes” in which the object can move but in my early code I’m getting an error and not sure why, I’m using the code from the movieclip tutorial. The error I’m getting is:

“Syntax error: /Users/carolineback/Desktop/Micke/Kodningar/main.lua:51: unexpected symbol near ‘[’”

And this is my code:

  
-- Initialize a second cube anim (this time by creating the image table dynamically)   
 imageTable = {}  
 for i = 1,4 do  
 table.insert( imageTable, "whale\_pre" .. i .. ".png" )  
 end  
  
-- Create myAnim2 object   
 myAnim2 = movieclip.newAnim( imageTable )  
 foreground:insert( myAnim2 )  
  
-- Add some frame labels (optional)  
 myAnim2:setLabels{left=3, right=4}  
  
-- Position myAnim2  
 myAnim2.x = 50  
 myAnim2.y = 300  
 local actions["button1"] = function()  
 myAnim2:play{ startFrame=3, endFrame=3, loop=1, remove=true }   
 transition.to(myAnim2, { time=2000, y=myAnim2.y+100, x=myAnim2.x+100 } )   
 end  
 actions["button2"] = function()  
 myAnim2:play{ startFrame=4, endFrame=4, loop=1, remove=true }   
 transition.to(myAnim2, { time=2000, y=myAnim2.y-100, x=myAnim2.x-100 } )   
 end  

myAnim2 consists of 4 png-files. 1 and 2 are the default animation and 3 is the character turning to the left, and 4 is the character turning to the right.

Any idea how this error could be avoided? Or do you even have a better programming solution to my animation?

Thank you [import]uid: 21652 topic_id: 5440 reply_id: 305440[/import]

That code you posted is obviously not all of it, since the error message points to line 51 but what you posted only has 26 lines.

Basically, when you see an error message the first thing you check is the line it points to. The second thing you check is the line right before it. From the message, I’m guessing you just made a syntax error (ie. a typo.) [import]uid: 12108 topic_id: 5440 reply_id: 18247[/import]

this:
[lua]local actions[“button1”] = function()[/lua]

try:

[lua]local actions = {}
actions[“button1”] = function()[/lua]

[import]uid: 6645 topic_id: 5440 reply_id: 18248[/import]

Ah, how could I forget something so fundamental as pointing out which line is nr 51… I’m sorry about that. “jmp909” guessed right though, that was line 51. Thanks, I’ll try that out as soon as when I get home.
Sorry about the lack of detailed as pointed out. [import]uid: 21652 topic_id: 5440 reply_id: 18254[/import]

That solution worked perfectly. Thank you jmp909! [import]uid: 21652 topic_id: 5440 reply_id: 18289[/import]