local thisActor = ... -- our stamina bar

local staminaAnimation = scaleform.Actor.component_by_name(thisActor, "animation")
local bar = scaleform.ContainerComponent.actor_by_name(staminaAnimation, "bar")
local barAnimation = scaleform.Actor.component_by_name(bar, "animation")

scaleform.AnimationComponent.stop(barAnimation)
scaleform.AnimationComponent.goto_frame(barAnimation, 32)

local customListener = scaleform.EventListener.create(customListener, function(e)
    if e.name == "stamina_changed" then
        scaleform.AnimationComponent.goto_frame(barAnimation, math.ceil(e.data.value*31/100)+1)
    end    
end );

scaleform.EventListener.connect(customListener, thisActor,scaleform.EventTypes.Custom)