User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

sample_code:view_sys_files

View Sys files

This code will display the image and sound files available in “/Sys/”

The code

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"]
var player,lay2,img
//Called when application is started.
function OnStart()
{
    app.EnableBackKey(false);
    app.SetOrientation("Portrait");
    //Create a layout with objects vertically centered.
    var lay = app.CreateLayout( "absolute", "VCenter,FillXY" );    
 
    player = app.CreateMediaPlayer(); 
    player.SetOnReady(playerReady);
    //Create a text label and add it to layout.
    var 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");
    //property to simulate GetBackColor()
    lay2.backColor="#ffdddddd"
    img=app.CreateImage(null,0.95,0.85);
    img.SetOnTouchUp(imgOnTouch);
    lay2.AddChild(img);
    //seekbar to change background colour
    var skb=app.CreateSeekBar(0.95);
    skb.SetRange(15);
    skb.SetValue(13);
    skb.SetOnTouch(skbOnTouch);
    skb.SetPosition(0,0.85,0.95)
    lay2.AddChild(skb);
    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 skbOnTouch(value)
{
     var h = Math.round(value).toString(16);
     var col = "#ff"+h+h+h+h+h+h;
     if(lay2.backColor != col)
     {
        lay2.SetBackColor(col);
        lay2.backColor = col;
     }
}
function playerReady()
{
        player.SeekTo(0);
        player.Play();
}
 
function OnBack()
{
    if(lay2.GetVisibility()=="Show")
        lay2.Animate("SlideToLeft")
    else if(confirm("Exit")) app.Exit()
}
sample_code/view_sys_files.txt · Last modified: 2015/09/24 14:16 (external edit)