Created
December 7, 2011 13:21
-
-
Save donayama/1442773 to your computer and use it in GitHub Desktop.
タイタにうもん第一話 サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (1) ウィンドウ(Window)を作る | |
var window = Titanium.UI.createWindow({ | |
backgroundColor : 'white' | |
}); | |
// (2)ボタン(Button)を作る | |
var button = Titanium.UI.createButton({ | |
title : 'カメラ', | |
top : 10, | |
left : 100, | |
right : 100, | |
height : 40 | |
}); | |
// (3)写真の表示部(ImageView)を作る | |
var view = Titanium.UI.createImageView({ | |
left : 10, | |
top : 60, | |
bottom : 10, | |
right : 10 | |
}); | |
// (4)ウィンドウに部品を格納する。 | |
window.add(button); | |
window.add(view); | |
// (5)ボタンを押したときのイベントを記述する(カメラを起動する) | |
button.addEventListener('click', function(e) { | |
Titanium.Media.showCamera({ | |
success : function(e) { | |
view.image = e.media; | |
}, | |
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO] | |
}); | |
}); | |
// (6)ウィンドウを開く | |
window.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment