I'm having trouble with including functions from another file.
I have 2 files app.js
and responsive.js
in responsive.js i have this:
// 100%
var per100 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 1.0);
// 90%
var per90 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.9);
// 80%
var per80 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.8);
// 60%
var per50 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.6);
// 50%
var per50 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.5);
// 40%
var per40 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.4);
// 25%
var per25 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.25);
// 10%
var per10 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.10);
// 5%
var per5 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.5);
// 1%
var per1 = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.1);
and in the app.js
file i have this:
// include needed files
Ti.include('responsive.js');
//Create the screen
//The home screen
var homeWindow = Ti.UI.createWindow({
exitOnClose: true,
fullscreen: false,
title: 'Advanced'
});
var homeView = Ti.UI.createView({
backgroundColor: 'white'
});
var homeLabel = Ti.UI.createLabel({
top: 20,
left: 30,
height: 30,
text: 'Login or register to start',
color: 'black',
font: {fontSize: 18}
});
var homeLoginButton = Ti.UI.createButton({
title: 'test',
backgroundColor: 'red',
top: 55,
left: 30,
width:per60,
height: 30,
color: 'black',
font: {fontSize: 14}
});
var homeRegisterButton = Ti.UI.createButton({
title: 'test2',
backgroundColor: 'blue',
top: 55,
left: 180,
width:per60,
height: 30,
color: 'black',
font: {fontSize: 14}
});
//Creating the application
//Home screen
homeWindow.add(homeView);
homeView.add(homeLabel);
homeView.add(homeLoginButton);
homeView.add(homeRegisterButton);
homeWindow.open();
everything is pretty easy but every time I try to start the application I get this error
Uncaught Reference error: per60 is not defined
How can i solve this issue?
You seem to have twice:
var per50
and no
var per60
in your first file