Need help swapping sprites

Alright guys so Im attempting to write a program in which the user controls a knight in order to fight a dragon (lame I know) but anyways I have the basic concept of using an image as a button down, the only thing I need to know is if there is any way to switch the sprite when the user presses the button. That way I can make it seem as if the knight is slashing at the dragon. Any ideas? Oh and I dont know much about Codea since I just started working with it today.

Hope this help.

function setup()
    img = readImage("Cargo Bot:Condition Blue")
    x = WIDTH/2
    y = HEIGHT/2
end


function draw()
    background(40, 40, 50)
    sprite(img,x,y)   
end

function touched(touch)
    if touch.state == ENDED then
        img = readImage("Cargo Bot:Condition Blue")
    else
        img = readImage("Cargo Bot:Condition Green")
    end
end

It didnt work
:confused:

it does, actually, the sprite changes while you hold your finger down, so if you change to a slashing picture for that, it will look good