local thisActor = ...

local totalTime = 0.0;
local dispatched = false;

local enterFrameEventListener = scaleform.EventListener.create(enterFrameEventListener, function(e, thisListener)
    local frameTime = scaleform.Stage.frame_time()
    totalTime = totalTime + frameTime
    if totalTime > 4 then
        if dispatched ~= true then
            local evt = { eventId = scaleform.EventTypes.Custom, 
                        name = "action",
                        data = { message = "change_level" } 
                        }
            scaleform.Stage.dispatch_event(evt)
            dispatched = true;
        end

        scaleform.EventListener.disconnect(thisListener)
    end
end )

scaleform.EventListener.connect(enterFrameEventListener, thisActor, scaleform.EventTypes.EnterFrame)