Developers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
oa24153
Binge Watcher

BRIGHTSCRIPT: ERROR: roSGNode.AddReplace: "url": Type mismatch: pkg:/components/home_scene.brs(62) f

I want to add timer to load my JSON file after every 5 sec but i'm getting this error. This is my code for selected category.

function loadFeed(url)
    ? "Change every 5 sec"
    ? "URL"url
    m.feed_task = CreateObject("roSGNode", "load_feed_task")
    m.feed_task.observeField("response", "onFeedResponse")

    m.feed_task.url = url
    m.feed_task.control = "RUN"
end function
function onFeedResponse(obj)
    response = obj.getData()
    ' turn the JSON string into an Associative Array
    fetch = ParseJson(response)
    tempStrechData = CreateObject("roArray", 0, true)
    m.global.addFields({ strechedData: [] })
    if fetch <> invalid and fetch.data <> invalid
        ' hide the category screen and show content screen
        m.category_screen.visible = false
        m.content_screen.visible = true
        ' assign data to content screen
        m.content_screen.feed_data = fetch

        tempStrechData.Push(fetch)
        ? tempStrechData
        m.global.strechedData = tempStrechData
        ? m.global.strechedData
    else
        ? "FEED RESPONSE IS EMPTY!"
    end if
end function

 

sub onCategorySelected(obj)
    ? "onCategorySelected field: "; obj.getField()
    ? "onCategorySelected data: "; obj.getData()
    list = m.category_screen.findNode("category_list")
    ? "onCategorySelected checkedItem: "; list.checkedItem
    ? "onCategorySelected selected ContentNode: "; list.content.getChild(obj.getData())
    item = list.content.getChild(obj.getData())

    m.global.AddField("url", "string", false)
    url = item.feed_url
    ' code for timer
    m.testtimer = m.top.findNode("testTimer")
    m.testtimer.control = "start"

    m.textchange = false

    m.testtimer.ObserveField("fire", "loadFeed")

    m.top.setFocus(true)
' code for timer
    ' loadFeed(url)

    ' loadFeed(item.feed_url)
end sub
Tags (1)
0 Kudos
Community is Temporarily in Read-Only Mode!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!