Change animation of factory created objects

I’m using a factory to create enemies which travel along a path, when they reach a corner I want them to change animation but no matter what I try they always stay with their default animation.

Please share the enemy script that’s not working.

local xPath = {130,733,733,130,130,733,733}
local yPath = {130,130,272,272,417,417,549}

local function movement (aim_checkpoint)
    if aim_checkpoint <8 then
	    if aim_checkpoint%2 == 1 then
		    go.animate(".",
"position.y",go.PLAYBACK_ONCE_FORWARD,yPath[aim_checkpoint],go.EASING_LINEAR, 5)
		    countdown=5
		    msg.post(".", "play_flipbook",{id = hash("walk away")})
	    else
		    go.animate(".", "position.x",go.PLAYBACK_ONCE_FORWARD,xPath[aim_checkpoint],go.EASING_LINEAR, 20.8)
	            if aim_checkpoint%4 == 0 then
			          print("animationchange")
			          msg.post(".", "play_flipbook",{id = hash("walk away")})
		         else
			          print("animationchange")
			          msg.post(".", "play_flipbook",{id = hash("walk away")})
		         end
		    countdown=20.8
	     end
	aim_checkpoint=aim_checkpoint+1
	print("cycle complete")
	timer.delay(countdown, false, function()movement(aim_checkpoint)end)
    end
end


function init(self)
    movement(1)
end    

This is my code for the enemy created by the factory

I would recommend that you use sprite.play_flipbook("#yourspriteid", hash("walk away")) instead of sending a message.

Are you getting an error by the way?

No errors
Sorry I’m away from home till the 5th.