slideView.lua: 55

How can a back button be placed on a lua file using the slideView library? Also when I use the slideView library I get this error below.
attempt to index local ‘p’ a nil value

  1. Would this mean all images in the set need to be exactly the same image size?

  2. Would I insert the back button using…

Local backButton = display.newImage(“back.png”)
insert:eventListener(backbutton)

Thanks.

this is ‘p’ in slideView.lua

images = {} for i = 1,#imageSet do local p = display.newImage(imageSet[i]) local h = viewableScreenH-(top+bottom) if p.width \> viewableScreenW or p.height \> h then if p.width/viewableScreenW \> p.height/h then p.xScale = viewableScreenW/p.width p.yScale = viewableScreenW/p.width else p.xScale = h/p.height p.yScale = h/p.height end end g:insert(p) [import]uid: 88495 topic_id: 35246 reply_id: 335246[/import]

No, it will load any sized image and if its bigger than the screen then it will be scaled to fit the display.

The only reason p would be nil is if the image doesn’t exist.
[import]uid: 199310 topic_id: 35246 reply_id: 140131[/import]

Director.lua:1092 in changeScene
Module must have a new() funtion
?

[code]

– Abstract: Slide View sample app

– Version: 1.0

– Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
– Copyright © 2010 Corona Labs Inc. All Rights Reserved.

– Demonstrates how to display a set of images in a series that
– the user can swipe from left to right, using the methods
– provided in slideView.lua.
module(…, package.seeall)
display.setStatusBar( display.HiddenStatusBar )
–local slideView = require(“slideView”)
local slideView = require(“slideView”)

local myImages = {
“aFive0.jpg”,
“aFive1.jpg”,
“aFive2.jpg”,
“aFive3.jpg”,
“aFive4.jpg”,
“aFive5.jpg”,
“aFive6.jpg”,
“aFive7.jpg”,
“aFive8.jpg”,
“aFive9.jpg”,
“aFive10.jpg”,
“aFive11.jpg”,
“aFive12.jpg”,
“aFive13.jpg”,
“aFive14.jpg”,
“aFive15.jpg”,
“aFive17.jpg”,
“aFive18.jpg”
}

–slideView.new( myImages )
local slide = slideView.new{
data = myImages,
callback = function(row1)
local group = display.newGroup()
local graph = display.newImage(row1, 0,0,true)
group:insert(graph)
return group
end
}

slideView.new( myImages, “arc3.png” )
slideView.new( myImages, nil, 40, 60 )

–[[

– Examples of other parameters:

– Show a background image behind the slides

slideView.new( myImages, “arc3.png” )

– Insert space at the top and bottom
slideView.new( myImages, nil, 40, 60 )

–]]

local back = display.newImage(“thisway.png”)

back.x = 690; back.y = 700

[/code] [import]uid: 88495 topic_id: 35246 reply_id: 140146[/import]

Are you building a Director app or a Storyboard app?

[import]uid: 199310 topic_id: 35246 reply_id: 140267[/import]

Dir app [import]uid: 88495 topic_id: 35246 reply_id: 140273[/import]

The error is very direct and straight forward. The code you posted in #2 appears to be a module you are calling from a director.changeScene() function call. That module must have a function called “new” and that function must return a display group. Your code above does neither.

Look at my differences:

[code]
– Abstract: Slide View sample app

– Version: 1.0

– Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
– Copyright © 2010 Corona Labs Inc. All Rights Reserved.

– Demonstrates how to display a set of images in a series that
– the user can swipe from left to right, using the methods
– provided in slideView.lua.
module(…, package.seeall)
display.setStatusBar( display.HiddenStatusBar )

function new() – required line
local localGroup = display.newGroup() --required line

local slideView = require(“slideView”)

local myImages = {
“aFive0.jpg”,
“aFive1.jpg”,
“aFive2.jpg”,
“aFive3.jpg”,
“aFive4.jpg”,
“aFive5.jpg”,
“aFive6.jpg”,
“aFive7.jpg”,
“aFive8.jpg”,
“aFive9.jpg”,
“aFive10.jpg”,
“aFive11.jpg”,
“aFive12.jpg”,
“aFive13.jpg”,
“aFive14.jpg”,
“aFive15.jpg”,
“aFive17.jpg”,
“aFive18.jpg”
}

local slide = slideView.new{
data = myImages,
callback = function(row1)
local group = display.newGroup()
local graph = display.newImage(row1, 0,0,true)
group:insert(graph)
return group
end
}

slideView.new( myImages, “arc3.png” ) – I don’t know what these two lines are doing
slideView.new( myImages, nil, 40, 60 ) – they are not returning a display object that you can put
– into a group. Consider removing them.

local back = display.newImage(“thisway.png”)

back.x = 690; back.y = 700

localGroup:insert(back) – add the background to the group
localGroup:insert(slide) – add the slideview to the group

return localGroup – required
[/code] [import]uid: 199310 topic_id: 35246 reply_id: 140278[/import]

No, it will load any sized image and if its bigger than the screen then it will be scaled to fit the display.

The only reason p would be nil is if the image doesn’t exist.
[import]uid: 199310 topic_id: 35246 reply_id: 140131[/import]

Director.lua:1092 in changeScene
Module must have a new() funtion
?

[code]

– Abstract: Slide View sample app

– Version: 1.0

– Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
– Copyright © 2010 Corona Labs Inc. All Rights Reserved.

– Demonstrates how to display a set of images in a series that
– the user can swipe from left to right, using the methods
– provided in slideView.lua.
module(…, package.seeall)
display.setStatusBar( display.HiddenStatusBar )
–local slideView = require(“slideView”)
local slideView = require(“slideView”)

local myImages = {
“aFive0.jpg”,
“aFive1.jpg”,
“aFive2.jpg”,
“aFive3.jpg”,
“aFive4.jpg”,
“aFive5.jpg”,
“aFive6.jpg”,
“aFive7.jpg”,
“aFive8.jpg”,
“aFive9.jpg”,
“aFive10.jpg”,
“aFive11.jpg”,
“aFive12.jpg”,
“aFive13.jpg”,
“aFive14.jpg”,
“aFive15.jpg”,
“aFive17.jpg”,
“aFive18.jpg”
}

–slideView.new( myImages )
local slide = slideView.new{
data = myImages,
callback = function(row1)
local group = display.newGroup()
local graph = display.newImage(row1, 0,0,true)
group:insert(graph)
return group
end
}

slideView.new( myImages, “arc3.png” )
slideView.new( myImages, nil, 40, 60 )

–[[

– Examples of other parameters:

– Show a background image behind the slides

slideView.new( myImages, “arc3.png” )

– Insert space at the top and bottom
slideView.new( myImages, nil, 40, 60 )

–]]

local back = display.newImage(“thisway.png”)

back.x = 690; back.y = 700

[/code] [import]uid: 88495 topic_id: 35246 reply_id: 140146[/import]

Are you building a Director app or a Storyboard app?

[import]uid: 199310 topic_id: 35246 reply_id: 140267[/import]

Dir app [import]uid: 88495 topic_id: 35246 reply_id: 140273[/import]

The error is very direct and straight forward. The code you posted in #2 appears to be a module you are calling from a director.changeScene() function call. That module must have a function called “new” and that function must return a display group. Your code above does neither.

Look at my differences:

[code]
– Abstract: Slide View sample app

– Version: 1.0

– Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
– Copyright © 2010 Corona Labs Inc. All Rights Reserved.

– Demonstrates how to display a set of images in a series that
– the user can swipe from left to right, using the methods
– provided in slideView.lua.
module(…, package.seeall)
display.setStatusBar( display.HiddenStatusBar )

function new() – required line
local localGroup = display.newGroup() --required line

local slideView = require(“slideView”)

local myImages = {
“aFive0.jpg”,
“aFive1.jpg”,
“aFive2.jpg”,
“aFive3.jpg”,
“aFive4.jpg”,
“aFive5.jpg”,
“aFive6.jpg”,
“aFive7.jpg”,
“aFive8.jpg”,
“aFive9.jpg”,
“aFive10.jpg”,
“aFive11.jpg”,
“aFive12.jpg”,
“aFive13.jpg”,
“aFive14.jpg”,
“aFive15.jpg”,
“aFive17.jpg”,
“aFive18.jpg”
}

local slide = slideView.new{
data = myImages,
callback = function(row1)
local group = display.newGroup()
local graph = display.newImage(row1, 0,0,true)
group:insert(graph)
return group
end
}

slideView.new( myImages, “arc3.png” ) – I don’t know what these two lines are doing
slideView.new( myImages, nil, 40, 60 ) – they are not returning a display object that you can put
– into a group. Consider removing them.

local back = display.newImage(“thisway.png”)

back.x = 690; back.y = 700

localGroup:insert(back) – add the background to the group
localGroup:insert(slide) – add the slideview to the group

return localGroup – required
[/code] [import]uid: 199310 topic_id: 35246 reply_id: 140278[/import]