<?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