Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Using Slider for 360 Effect

I'm trying to use the Slider to use in conjunction with 36 images to make a 360º view of it. I'm fairly new to Titanium and don't really know how to make this work. Any help would be greatly appreciated! Thanks!

— asked July 15th 2010 by Travis Moore
  • images
  • iphone
0 Comments

2 Answers

  • You could name your images like this:
    0.png, 1.png, 2.png, etc…

    Display an imageView with

    image:0.png
    

    Then create the slider and on the change event do this:

    slider.addEventListener( 'change', function(e) {
    
    the_image.image = parseInt(e.value)+'.png'
    })
    

    //code untested :)

    — answered July 15th 2010 by Dan Tamas
    permalink
    1 Comment
    • This is the code I'm trying to use:

      
      // Get Current Window
      var currentWin = Ti.UI.currentWindow;
      
      var images = [];
      for (var c=0;c<36;c++)
      {
          images[c]= 'images/sfh-18/'+c+'.png';
      }
      
      var imageView = Titanium.UI.createView({
          width:310,
          height:233,
          top:10
      });
      imageView.add(images);
      currentWin.add(imageView);
      
      var basicSlider = Titanium.UI.createSlider({
          min:0,
          max:35,
          value:1,
          width:100,
          height:'auto',
          top:300
      });
      basicSlider.addEventListener('onChange', function(e)
      {
          imageView.backgroundImage = images[e.value];
      });
      
      currentWin.add(basicSlider);
      

      I still can't seem to get it to work. Also, I don't know very much about JS, so that could be the problem. :)

      — commented July 20th 2010 by Travis Moore
  • Ok figured it out. It works beautifully!

    var imageView = Titanium.UI.createView({
        backgroundImage:'',
        width:310,
        height:233,
        top:10
    });
    
    currentWin.add(imageView);
    
    var basicSlider = Titanium.UI.createSlider({
        min:0,
        max:35,
        value:1,
        width:100,
        height:'auto',
        top:300
    });
    basicSlider.addEventListener('change', function(e)
    {
        Ti.API.info("basicSlide value is: " + basicSlider.value);
        imageView.backgroundImage = 'images/sfh-18/' + Math.round(basicSlider.value + 1) + '.png';
    
    });
    

    Hope this helps someone!

    — answered July 20th 2010 by Travis Moore
    permalink
    1 Comment
    • I dont understand the function oif slider. Why not control the picture with gesture over picture – like: http://tools.webmasterei.com/offenburg/2.html

      — commented September 26th 2011 by Rainer Schleevoigt
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.