//Called when application is started. function OnStart() { app.SetOrientation("Portrait"); //Create a layout with objects vertically centered. lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); //Create an absolute layout so we can position objects. layAbs = app.CreateLayout( "Absolute" ); lay.AddChild( layAbs ); //Create first image. img1 = app.CreateImage( null, 0.5, 0.3 ); img1.SetColor("#66000088"); img1.SetOnTouchDown(img_OnTouch); layAbs.AddChild( img1 ); //Create second image. img2 = app.CreateImage( null, 0.5, 0.3 ); img2.SetColor("#66880000"); img2.SetPosition( 0.1,0.1 ); img2.SetOnTouchDown(img_OnTouch); layAbs.AddChild( img2 ); //Create third image in middle img3 = app.CreateImage( null, 0.5, 0.3 ); img3.SetColor("#66008800"); img3.SetPosition( 0.2,0.2 ); img3.SetOnTouchDown(img_OnTouch); layAbs.AddChild( img3,1 ); //Add layout to app. app.AddLayout( lay ); } //Called when user touches image function img_OnTouch(){ childToBack(layAbs, this) } function childToBack(layt, obj){ if( layt.GetChildOrder( obj ) > 0 ){ layt.RemoveChild(obj); layt.AddChild(obj,0); } }