<?xml version="1.0" encoding="utf-8" ?>
<component name = "postergridCR" extends = "Task" >
<interface>
<field id = "postergriduri" type = "string" />
<field id = "postergridcontent" type = "string"/>
</interface>
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.functionName = "getContent"
end sub
sub getContent()
readInternet = createObject("roUrlTransfer")
readInternet.setUrl(m.top.postergriduri)
postergridcontent = readInternet.GetToString()
m.top.postergridcontent = postergridcontent
end sub
]]>
</script>
</component>
function getwebcontent(webpage as string)
m.myObj = createObject("RoSGNode", "postergridCR")
m.myObj.postergriduri=webpage
m.myObj.functionName="getcontent"
m.myObj.control = "RUN"
return m.myObj.postergridcontent <<======== How do I return the content ??
end function
<?xml version = "1.0" encoding = "utf-8" ?>
<component name = "ContentReader" extends = "Task" >
<interface>
<field id = "contenturi" type = "uri" />
<field id = "content" type = "node" />
</interface>
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.functionName = "getcontent"
end sub
sub getcontent()
content = createObject("roSGNode", "ContentNode")
contentxml = createObject("roXMLElement")
readInternet = createObject("roUrlTransfer")
readInternet.setUrl(m.top.contenturi)
contentxml.parse(readInternet.GetToString())
if contentxml.getName()="Content"
for each item in contentxml.GetNamedElements("item")
itemcontent = content.createChild("ContentNode")
itemcontent.setFields(item.getAttributes())
end for
end if
m.top.content = content
end sub
]]>
</script>
</component>
<component name = "SimplePosterGrid" extends = "Scene" initialFocus = "postergrid" >
<interface>
<field id="itemContent" type="node" onChange="showpostergrid"/>
</interface>
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.postergrid = m.top.findNode("PosterGrid")
m.readPosterGridTask = createObject("roSGNode", "ContentReader")
m.readPosterGridTask.contenturi = "http://yourfilehere.xml"
m.readPosterGridTask.observeField("content", "showpostergrid")
m.readPosterGridTask.control = "RUN"
end sub
sub showpostergrid()
m.postergrid.content = m.readPosterGridTask.content
m.postergrid.setFocus(true)
end sub
]]>
</script>
<children>
<PosterGrid
id = "PosterGrid"
basePosterSize = "[ 375, 225 ]"
numColumns = "4"
numRows = "3"
itemSpacing = "[ 50, 75 ]" />
</children>
</component>
sub getContent()
readInternet = createObject("roUrlTransfer")
readInternet.setUrl(m.top.postergriduri)
postergridcontent = readInternet.GetToString()
m.top.postergridcontent = postergridcontent
end sub
sub getContent()
m.readInternet = createObject("roUrlTransferTask")
m.readInternet.observeField("content","contentSet")
m.readInternet.Url = m.top.postergriduri
end sub
sub contentSet
m.top.postergridcontent = m.readInternet.content
end sub
<interface>
<field id = "postergriduri" type = "string" />
<field id = "postergridcontent" type = "string"/>
<field id = "content" type = "string" />
</interface>
<?xml version="1.0" encoding="utf-8" ?>
<component name = "postergridCR" extends = "Task" >
<interface>
<field id = "postergriduri" type = "string" />
<field id = "postergridcontent" type = "string"/>
<field id = "content" type = "string" />
</interface>
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.functionName = "getData"
end sub
sub getContent()
m.readInternet = createObject("roUrlTransfer")
m.readInternet.observeField("content","contentSet")
m.readInternet.Url = m.top.postergriduri
end sub
sub contentSet()
m.top.postergridcontent = m.readInternet.content
end sub
]]>
</script>
</component>
getwebcontent ("http://example.com")
function getwebcontent(webpage as string)
m.myObj = createObject("RoSGNode", "postergridCR")
m.myObj.postergriduri=webpage
m.myObj.functionName="getcontent"
m.myObj.control = "RUN"
return m.myObj.postergridcontent
end function
function getwebcontent(webpage as string)
m.myObj = createObject("RoSGNode", "postergridCR")
m.myObj.postergriduri=webpage
m.myObj.functionName="getcontent"
m.myObj.observeField("postergridcontent","gotContent") '<===================== CREATE OBSERVER BEFORE RUN'
m.myObj.control = "RUN"
end function
sub gotContent()
content = m.myObj.postergridcontent '<================== callback triggered when task sets m.top.postergridcontent'
end sub
sub gotContent()
m.top.content = m.haamro.HTTPcontent
print m.top.content <======== This works
end sub
function myotherfunction(url)
getWebContent (url)
print m.top.content <======= this does not work
end function
m.haamro.HTTPcontent
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!