Skip to content

Instantly share code, notes, and snippets.

View alanleard's full-sized avatar

Alan Leard alanleard

View GitHub Profile
@alanleard
alanleard / app.js
Created January 7, 2012 00:12
Remote Notification in App Action
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
backgroundColor: 'white'
@alanleard
alanleard / app.js
Created January 5, 2012 22:32
Image Display webview vs image
var win = Ti.UI.createWindow();
var webview = Ti.UI.createWebView({
html:'<html><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><img src="http://b.vimeocdn.com/ps/929/929705_300.jpg"></html>'
});
win.add(webview);
// var image =Ti.UI.createImageView({
// image:'http://b.vimeocdn.com/ps/929/929705_300.jpg',
// width:'100%',
@alanleard
alanleard / app.js
Created December 19, 2011 22:24
Shake Animation
var win = Ti.UI.createWindow();
function shakeAnimation(view, count, distance, speed) {
var anim1 = Ti.UI.createAnimation({
duration:speed/2,
left:view.left-(distance/2),
curve: Ti.UI.iOS.ANIMATION_CURVE_EASE_IN
});
var anim2 = Ti.UI.createAnimation({
@alanleard
alanleard / app.js
Created December 19, 2011 22:09
Center Shake
var win = Ti.UI.createWindow();
function shakeAnimation(view, count, distance) {
var anim1 = Ti.UI.createAnimation({
duration:50,
left:view.left-distance,
autoreverse:true,
curve:Ti.UI.iOS.ANIMATION_CURVE_LINEAR
});
@alanleard
alanleard / app.js
Created December 19, 2011 22:02
Simple Shake
var win = Ti.UI.createWindow();
function shakeAnimation(view, count, distance) {
var anim1 = Ti.UI.createAnimation({
duration:100,
left:view.left-distance,
autoreverse:true,
curve:Ti.UI.iOS.ANIMATION_CURVE_LINEAR,
repeat:count
@alanleard
alanleard / app.js
Created December 19, 2011 21:33
Wobble
var win = Ti.UI.createWindow();
function shakeAnimation(view) {
view.transform = Ti.UI.create2DMatrix().rotate(1);
var r1 = Ti.UI.create2DMatrix().rotate(2);
var r2 = Ti.UI.create2DMatrix().rotate(-2);
var anim1 = Ti.UI.createAnimation({
duration:200,
transform:r1,
@alanleard
alanleard / app.js
Created December 14, 2011 02:46
Network Speed Test
var win = Ti.UI.createWindow();
var start = new Date().getTime();
var c = Titanium.Network.createHTTPClient({validatesSecureCertificate:false});
c.ondatastream = function(){
//start = new Date().getTime();
};
c.onload = function()
{
Ti.API.info('IN ONLOAD ');
@alanleard
alanleard / app.js
Created December 6, 2011 05:09
Indicators on Tabgroup & TabbedBar
var win = Ti.UI.createWindow();
var tabGroup = Ti.UI.createTabGroup();
function indicator(count, top, left, color){
var label = Ti.UI.createLabel({
backgroundColor:color,
text:count,
borderColor:'#fff',
borderRadius:10,
@alanleard
alanleard / app.js
Created November 29, 2011 19:58
Dynamic Image Add to ScrollView
var win = Ti.UI.createWindow();
var scrollView = Ti.UI.createScrollView({
contentWidth:'auto',
contentHeight:'auto',
left:0, right:0,
top:200
});
var imageCount = 24;
@alanleard
alanleard / app.js
Created November 29, 2011 18:21
Drag & Drop Blocks
var win = Titanium.UI.createWindow();
var item1 = Ti.UI.createView({
top:166,
left:180,
height:87,
width:60,
backgroundColor:'blue'
});