Dynamic Sprite Sheets don't work for buttons

I dynamically load sprites from many many spritesheets on demand following the idiom of

getSpriteGfx = function(group, spritespath, spritename) local imagePath = string.gsub(spritespath,"%.","/") -- magic characters escaped with percentage local imageNfo = require("images.sprites."..spritespath) local imageSheet = graphics.newImageSheet( "images/sprites/"..imagePath..".png", imageNfo:getSheet() ) local imageRect = display.newImageRect( group, imageSheet, imageNfo:getFrameIndex(spritename), imageNfo.sheet.frames[imageNfo:getFrameIndex(spritename)].width, imageNfo.sheet.frames[imageNfo:getFrameIndex(spritename)].height ) unrequire("images.sprites"..spritespath) imageNfo = nil imageSheet = nil return imageRect end

function unrequire(m) package.loaded[m] = nil rawset(\_G, m, nil) -- Search for the shared library handle in the registry and erase it local registry = debug.getregistry() local nMatches, mKey, mt = 0, nil, registry['\_LOADLIB'] for key, ud in pairs(registry) do if type(key) == 'string' and type(ud) == 'userdata' and getmetatable(ud) == mt and string.find(key, "LOADLIB: .\*" .. m) then nMatches = nMatches + 1 if nMatches \> 1 then return false, "More than one possible key for module '" .. m .. "'. Can't decide which one to erase." end mKey = key end end if mKey then registry[mKey] = nil end return true end

So I can quickly grab any sprite and blit to the scene from a number of sources in a single frame’s time. 

When I use buttons, they require a sheet in scope, if I understand correctly. I’m not sure how to cleanly generate buttons using a similar method, with similar constraints (source images are across multiple large sheets - 2048x2048 so I have to limit how many I keep in scope).

Does someone have a clean way to do buttons in a dynamic way, like sprites?