Last week I wrote an article on Getting Started with Appcelerator in 10 Easy Steps. This week I am going to show you how to write your first application in Appcelerator.
App.js will already contain a bunch of generated code. You can delete all over this code, we will be writing our own in there.
For our first application, we are going to create a very simple application that has a black background with a welcome message.
The great thing about Appcelerator is that if you can already write in Javascript, then you are going to find the learning curve very simple.
The code to put into App.js is as follows:
var win;
var label;
function init() {
// We create a new Window with a black background.
win = Ti.UI.createWindow({
backgroundColor: ‘#000000′
})
// next we create a label that will be formatted to have white centred text
label = Ti.UI.createLabel({
color: ‘#ffffff’,
font: {fontSize: 36, fontFamily: “Courier”, fontWeight: 900},
textAlign: ‘center’
})
// give the label the text
label.text = “My first application
”;
}
function load() {
// add the label to the window
win.add(label);
// load the window
win.open();
}
init();
load();
Save app.js and press the green arrow on the main toolbar to run the app in your chosen emulator. It should load up and look like this:
Congratulations, you have just created your first appcelerator app
If you have any questions or comments, feel free to let me know!
One Response to Appcelerator tutorial – Writing your first app
Leave a Reply Cancel reply
Recent Comments
Archives
Categories










[...] Sam Weaver rebooted his blog with writing your first Appcelerator app. [...]