Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
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
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.