User Tools

Site Tools


sample_code:view_sys_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sample_code:view_sys_files [2015/09/23 12:30]
stevegarman created
sample_code:view_sys_files [2015/09/24 14:16]
Line 1: Line 1:
-====== View Sys files ==== 
-This code will display the image and sound files available in "/Sys/" 
  
-===== The code ===== 
- 
-<code JavaScript sysFiles.js> 
-var arr=["/Sys/Img/AScript.png","/Sys/Img/Add.png","/Sys/Img/BarA.png","/Sys/Img/BlackBack.jpg","/Sys/Img/BlueBack.jpg","/Sys/Img/Bulb.png","/Sys/Img/Color.png","/Sys/Img/Connect.png","/Sys/Img/Droid1.png","/Sys/Img/Droid2.png","/Sys/Img/Eagle1.png","/Sys/Img/Eagle2.png","/Sys/Img/Exit.png","/Sys/Img/Explode1.png","/Sys/Img/Explode2.png","/Sys/Img/Explode3.png","/Sys/Img/Explode4.png","/Sys/Img/Explode5.png","/Sys/Img/Files.png","/Sys/Img/Forward.png","/Sys/Img/GreenBack.jpg","/Sys/Img/Hello.png","/Sys/Img/Icon.png","/Sys/Img/JoyPad.png","/Sys/Img/Layout.png","/Sys/Img/Left.png","/Sys/Img/Light.png","/Sys/Img/Mic.png","/Sys/Img/NxtConn.png","/Sys/Img/Pillar.png","/Sys/Img/PillarTop.png","/Sys/Img/Play.png","/Sys/Img/Refresh.png","/Sys/Img/Reverse.png","/Sys/Img/Right.png","/Sys/Img/Settings.png","/Sys/Img/Sky.jpg","/Sys/Img/Sound.png","/Sys/Img/Splat.png","/Sys/Img/Spring.png","/Sys/Img/Sprint.png","/Sys/Img/StarField.jpg","/Sys/Img/Tab.png","/Sys/Img/TabHi.png","/Sys/Img/Tile.png","/Sys/Img/Touch.png","/Sys/Img/Ultra.png","/Sys/Img/VBarA.png","/Sys/Img/VBarB.png","/Sys/Img/VBarC.png","/Sys/Img/Xylophone.png","/Sys/Img/bar_dark.png","/Sys/Img/ioio.png","/Sys/Snd/Bullet.mp3","/Sys/Snd/Explode.mp3","/Sys/Snd/Poing.ogg","/Sys/Snd/Trill.ogg"] 
-//Called when application is started. 
-function OnStart() 
-{ 
-    app.EnableBackKey(false); 
-    //Create a layout with objects vertically centered. 
-    lay = app.CreateLayout( "absolute", "VCenter,FillXY" );     
- 
-    player = app.CreateMediaPlayer();  
-    player.SetOnReady(playerReady); 
-    //Create a text label and add it to layout. 
-    lst = app.CreateList( arr ); 
-    lst.SetOnTouch(lstOnTouch); 
-    lst.SetPosition(0,0.05); 
-    lay.AddChild( lst ); 
- 
-    //Add layout to app.     
-    app.AddLayout( lay ); 
-    
-    lay2=app.CreateLayout("absolute",""); 
-    lay2.SetBackColor("#ffdddddd"); 
-    lay2.SetBackground("/Sys/Img/Sky.jpg","repeat"); 
-    img=app.CreateImage(null,0.95,0.95); 
-    img.SetOnTouchUp(imgOnTouch); 
-    lay2.AddChild(img); 
-    lay2.SetVisibility("Hide"); 
-    app.AddLayout(lay2); 
-} 
- 
-function lstOnTouch(item) 
-{ 
-    if(!app.FileExists(item)) return 
-    var three=item.slice(-3) 
-    if (three=="png" || three=="jpg") 
-    { 
-      var pic = app.CreateImage(item); 
-      img.Clear(); 
-      img.DrawImage(pic,0,0,pic.GetWidth(),pic.GetHeight()); 
-      lay2.Animate("SlideFromLeft");   
-    } 
-    if (three=="mp3" || three=="ogg") 
-    { 
-        player.SetFile(item); 
-        player.SeekTo(0); 
-        player.Play(); 
-    } 
-} 
- 
-function imgOnTouch() 
-{ 
-     lay2.Animate("SlideToLeft"); 
-} 
-function playerReady() 
-{ 
-        player.SeekTo(0); 
-        player.Play(); 
-} 
- 
-function OnBack() 
-{ 
-    if(lay2.GetVisibility()=="Show") 
-        lay2.Animate("SlideToLeft") 
-    else if(confirm("Exit")) app.Exit() 
-} 
- 
-</code> 
sample_code/view_sys_files.txt · Last modified: 2015/09/24 14:16 (external edit)