Access a png and audio image in a function?

Is there a way to access a png and music/sound effects as objects in a function? I was planning on using a function which would bring up a melody and an image based on what number is randomly generated. While I don’t have the code set up in Lua, I could go over what I want it to do in pseudo-code.

local function theFunction (x, y, z)
{
if randomNumber == x
{
start y
display z
}
}

Then run it sort of like…

theFunction(1, melody1, png1)

I’m not sure if this is doable in Corona or not. Any assistance would be greatly appreciated!

Sure. You should take a look at the guides: https://docs.coronalabs.com/guide/index.html#graphics-audio-animation

Remember to use the audio.loadSound to load all audio first. At the end of everything, dispose of it using audio.dispose. If you have sync problem, try other audio file formats like MP3 or WAV.