Close a slideView

Hey all!

I’m attempting to create a list, which displays some exorcises, and upon clicking an item in that list, a slideshow will be launched using slideView to show examples of how to do the exorcise. However, I’m having trouble getting a back button to work, I’m not sure how to ‘close’ the slideView once I have opened it. The code I’ve got so far is below:

[lua]local tableView = require(“tableView”) --import the table view library
local slideView = require(“slideView”) --import the slide view library
local ui = require(“ui”) --import the button events library

display.setStatusBar( display.HiddenStatusBar )

–initial values
local screenOffsetW, screenOffsetH = display.contentWidth - display.viewableContentWidth, display.contentHeight - display.viewableContentHeight

local myList, backBtn, detailScreenText

local background = display.newRect(0, 0, display.contentWidth, display.contentHeight)
background:setFillColor(77, 77, 77)

–setup a destination for the list items
local detailScreen = display.newGroup()

local detailBg = display.newRect(0,0,display.contentWidth,display.contentHeight-display.screenOriginY)
detailBg:setFillColor(255,255,255)
detailScreen:insert(detailBg)

detailScreenText = display.newText(“You tapped item”, 0, 0, native.systemFontBold, 24)
detailScreenText:setTextColor(0, 0, 0)
detailScreen:insert(detailScreenText)
detailScreenText.x = math.floor(display.contentWidth/2)
detailScreenText.y = math.floor(display.contentHeight/2)
detailScreen.x = display.contentWidth

local Images = {
Part_1 = {
{
“graphics/part_1/dumbbell-hang-pull-A.jpg”,
“graphics/part_1/dumbbell-hang-pull-B.jpg”,
},
{
“graphics/part_1/Offset-dumbbell-reverse-lunge-A.jpg”,
“graphics/part_1/Offset-dumbbell-reverse-lunge-B.jpg”,
},
{
“graphics/part_1/Single-arm-dumbbell-swing-A.jpg”,
“graphics/part_1/Single-arm-dumbbell-swing-B.jpg”,
},
{
“graphics/part_1/Single-arm-dumbbell-swing-A.jpg”,
“graphics/part_1/Single-arm-dumbbell-swing-B.jpg”,
},
{
“graphics/part_1/Thrusters-A.jpg”,
“graphics/part_1/Thrusters-B.jpg”,
“graphics/part_1/Thrusters-C.jpg”,
},
{
“graphics/part_1/Single-leg-single0arm-underhand-grip-dumbbell-row-A.jpg”,
“graphics/part_1/Single-leg-single0arm-underhand-grip-dumbbell-row-B.jpg”,
},
},
}

–setup functions to execute on touch of the list view items
function listButtonRelease( event )
self = event.target
local id = self.id
print(self.id)

–detailScreenText.text = "You tapped item "… self.id
slideView.new( Images[“Part_1”][self.id], nil, 40 )

transition.to(myList, {time=400, x=display.contentWidth*-1, transition=easing.outExpo })
transition.to(detailScreen, {time=400, x=0, transition=easing.outExpo })
transition.to(backBtn, {time=400, x=math.floor(backBtn.width/2) + screenOffsetW*.5 + 6, transition=easing.outExpo })
transition.to(backBtn, {time=400, alpha=1 })

delta, velocity = 0, 0
end

function backBtnRelease( event )
print(“back button released”)
transition.to(myList, {time=400, x=0, transition=easing.outExpo })
transition.to(detailScreen, {time=400, x=display.contentWidth, transition=easing.outExpo })
transition.to(backBtn, {time=400, x=math.floor(backBtn.width/2)+backBtn.width, transition=easing.outExpo })
transition.to(backBtn, {time=400, alpha=0 })

delta, velocity = 0, 0
end

local topBoundary = display.screenOriginY + 40
local bottomBoundary = display.screenOriginY + 0

–add some items that have arbitrary categories
local exorcises = {
PART1 = {
“Dumbbell Hang Pull”, “Dumbbell Reverse Lunge”, “Single-Arm Dumbbell Swing”, “Thrusters”, “Underhand-Grip Dumbbell Row”
},
PART2 = {
“Dumbbell Chop”, “Plank Walkup to Pushup”, “Dumbbell Strait-Leg Deadlift”, “Squat Thrusts”, “Jump Squat”
}
}

– setup some data
local data = {}

for i = 1, 5 do
data[i] = {}
data[i].title = exorcises[“PART1”][i]
data[i].category = “Part 1”
end

for i = 6, 10 do
data[i] = {}
data[i].title = exorcises[“PART2”][i-5]
data[i].category = “Part 2”
end

–specify the order for the groups in each category
local headers = { “Part 1”, “Part 2” }

– Create a list with header titles
myList = tableView.newList{
data=data,
default=“graphics/ui/listItemBg.png”,
over=“graphics/ui/listItemBg_over.png”,
onRelease=listButtonRelease,
top=topBoundary,
bottom=bottomBoundary,
cat=“category”,
order=headers,
categoryBackground=“graphics/ui/catBg.png”,
backgroundColor={ 255, 255, 255 },
callback=function(item)
local t = display.newText(item.title, 0, 0, native.systemFontBold, textSize)
t:setTextColor(0, 0, 0)
t.x = math.floor(t.width/2) + 12
t.y = 46
return t
end
}

–Setup the nav bar
local navBar = display.newImage(“graphics/ui/navBar.png”, 0, 0, true)
navBar.x = display.contentWidth*.5
navBar.y = math.floor(display.screenOriginY + navBar.height*0.5)

local navHeader = display.newText(“Spartacus Workout”, 0, 0, native.systemFontBold, 16)
navHeader:setTextColor(255, 255, 255)
navHeader.x = display.contentWidth*.5
navHeader.y = navBar.y

–Setup the back button
backBtn = ui.newButton{
default = “graphics/ui/backButton.png”,
over = “graphics/ui/backButton_over.png”,
onRelease = backBtnRelease
}
backBtn.x = math.floor(backBtn.width/2) + backBtn.width + screenOffsetW
backBtn.y = navBar.y
backBtn.alpha = 0[/lua] [import]uid: 45551 topic_id: 7884 reply_id: 307884[/import]