Simple Image Gallery Please Help

You must Login before you can answer or comment on any questions.

I'm trying to make a simple image gallery but I keep running into errors could some please help me I'm a noob to this stuff.. I want to make a home tab and a gallery tab and have the gallery scrollable.

This is the code i have so far: Titanium.UI.setBackgroundColor('#000');

// create tab group var tabGroup = Titanium.UI.createTabGroup();

// // create base UI tab and root window // var win1 = Titanium.UI.createWindow({
title:'Tab 1', navBarHidden: true //backgroundColor:'#fff'

}); var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png', title:'Home', window:win1 });

var tab2 = Titanium.UI.createTab({
icon:'KS_nav_views.png', title:'Gallery', window:win1 });

var label1 = Titanium.UI.createLabel({ backgroundImage: 'coffeeLogo.jpg', width: 320, height: 480, //color:'#999', //font:{fontSize:20,fontFamily:'Helvetica Neue'}, //textAlign:'center',

});

//scrollview

scrollingView = Titanium.UI.createScrollableView({ left: 17, top: 15, width: win1.width - 14, height: win1.height - 25, views: [], currentPage: 0, zIndex: 1 }); scrollingView.addEventListener('scroll',function(e){ Ti.API.info('Current scrollableView page = ' + e.source.currentPage); }); win1.add(scrollingView);

Ti.API.debug('Our type was: '+event.mediaType); if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
// set image view var imgView = Titanium.UI.createImageView({ top: 0, left: 0, width: 286, height: 337, image: image }); scrollingView.addView(imgView); }

— asked 8 months ago by Jamie Fudge
4 Comments
  • It usually helps to post the error that you're running into, along with the environment that you're building with. See the info requested on the ask a question page for the info you should post with your question.

    Lastly, you really need to properly format your code. There is a markdown syntax header on the text area if you don't already know it.

    — commented 8 months ago by Anthony Decena

  • If it helps the error i keep getting is

    [ERROR] Script Error = Can't find variable: event at app.js (line 64).

    — commented 8 months ago by Jamie Fudge

  • Sorry I just started learning this stuff a week ago. I'm doing a mobile project for iphone and ipad.

    — commented 8 months ago by Jamie Fudge

  • Show 1 more comment

2 Answers

— answered 8 months ago by Aaron Saunders
answer permalink
3 Comments
  • scrollingView.addEventListener('scroll',function(e){})
    In your eventHandler function you have the variable e and inside the function you reference it as event
    event.mediaType

    — commented 8 months ago by Stephen Feather

  • well, darn

    — commented 8 months ago by Stephen Feather

  • How do I fix this error? I got the code from the book: Titanium App Development Cookbook. Not sure what I'm doing wrong..

    — commented 8 months ago by Jamie Fudge

scrollingView.addEventListener('scroll',function(e){})
In your eventHandler function you pass in params as the variable e and inside the function you reference it as event
event.mediaType

— answered 8 months ago by Stephen Feather
answer permalink
4 Comments
  • well, it sounds like the code source you obtained has errors in it. Try changing your code to:

    scrollingView.addEventListener('scroll',function(event){
    instead of
    scrollingView.addEventListener('scroll',function(e){

    — commented 8 months ago by Stephen Feather

  • Tried it still gives the same error.

    — commented 8 months ago by Jamie Fudge

  • does anyone know have a different code i could use to make the scrolling gallery?

    — commented 8 months ago by Jamie Fudge

  • Show 1 more comment

Your Answer

This question has been locked and cannot accept new answers.