Syntax error..

You must Login before you can answer or comment on any questions.

Hey everybody, I don't understand whats wrong I have checked and double checked everything in my script but can't get it to work. I have even checked with other scripts and compared it to see if something wrong but it is not running and it said theres a syntax error at line 142

var startscreen = Ti.UI.createWindow({ title:'Start screen', exitOnClose:true, backgroundColor:'white' });

var buttonWolf1 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-WolfSquare.png', id:"Wolf1", width:40, height:40, top:20, left:20, title: " Wolf1 "

});

var buttonWolf2 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-WolfSquare.png', id:"Wolf2", width:40, height:40, top:20, left:70, title: " Wolf2 "

});

var buttonWraith1 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-WraithSquare.png', id:"Wraith1", width:40, height:40, top:50, left:100, title: " Wraith1 "

});

var buttonWraith2 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-WraithSquare.png', id:"Wraith2", width:40, height:40, top:50, left:70, title: " Wraith2 "

});

var buttonGolem1= Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-GolemSquare.png', id:"Golem1", width:40, height:40, top:80, left:100, title: " Golem1 "

});

var buttonGolem2 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-GolemSquare.png', id:"Golem2", width:40, height:40, top:80, left:70, title: " Golem2 "

});

var buttonLizElder1 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/Blessing_of_the_Lizard_Elder.png', id:"LizElder1", width:40, height:40, top:110, left:100, title: " LizElder1 "

});

var buttonLizElder2 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/Blessing_of_the_Lizard_Elder.png', id:"LizElder2", width:40, height:40, top:110, left:100, title: " LizElder2 "

});

var buttonAncGolem1 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/Crest_of_the_Ancient_Golem.png', id:"AncGolem1", width:40, height:40, top:140, left:70, title: " AncGolem1 "

});

var buttonAncGolem2 = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/Crest_of_the_Ancient_Golem.png', id:"AncGolem2", width:40, height:40, top:140, left:100, title: " AncGolem2 "

});

var buttonBaron = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-Baron_Nashor.png', id:"Baron", width:40, height:40, top:170, left:70, title: " Baron "

});

var buttonDragon = Ti.UI.createButton({ backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures/120px-DragonSquare.png', id:"Dragon", width:40, height:40, top:170, left:100, title: " Dragon "

});

win.add(buttonWolf1); <----------- LINE 142 win.add(buttonWolf2); win.add(buttonWraith1); win.add(buttonWraith2); win.add(buttonGolem1); win.add(buttonGolem2); win.add(buttonLizElder1); win.add(buttonLizElder2); win.add(buttonAncGolem1); win.add(buttonAncGolem2); win.add(buttonBaron); win.add(buttonDragon);

win.open(startscreen);

— asked 8 months ago by Gus Johansson
2 Comments
  • What happens if you comment that line out??

    — commented 8 months ago by Anthony Decena

  • Hi,

    If i comment that line out the syntax error moves to line 143.

    I get the error message [ERROR] Script Error = Can't find variable: win at app.js (line 143).

    — commented 8 months ago by Gus Johansson

2 Answers

Accepted Answer

First of all:

backgroundImage:'/Users/local/STUDENT/s2859014/Documents/Titanium_Studio_Workspace/Efficient Jungler/Resources/pictures

Thats not going to work for long (if its even working now)

Second, your code is either incomplete, or you have never actually declared a win variable.

— answered 8 months ago by Stephen Feather
answer permalink
1 Comment
  • startscreen.add(buttonWolf1); 
    startscreen.add(buttonWolf2); startscreen.add(buttonWraith1); startscreen.add(buttonWraith2); startscreen.add(buttonGolem1); startscreen.add(buttonGolem2); startscreen.add(buttonLizElder1); startscreen.add(buttonLizElder2); startscreen.add(buttonAncGolem1); startscreen.add(buttonAncGolem2); startscreen.add(buttonBaron); startscreen.add(buttonDragon);
    startscreen.open(startscreen);

    — commented 8 months ago by Stephen Feather

Uh, looks like because your window var is "startscreen" not "win".

Your Answer

Think you can help? Login to answer this question!