BrightSign BrightScript 2 Reference Guide User Manual

Page 18

Advertising
background image

18

owner=invalid As dynamic) As Object

photolist=CreateObject("roList")
for each photo in xmllist
photolist.Push(newPhotoFromXML(http, photo, owner))
next
return photolist

End Function

REM
REM newPhotoFromXML
REM
REM Takes an roXMLElement Object that is an <photo> ... </photo>
REM Returns an brs object of type Photo
REM photo.GetTitle()
REM photo.GetID()
REM photo.GetURL()
REM photo.GetOwner()
REM

Function newPhotoFromXML(http As Object, xml As Object, owner As dynamic) As
Object
photo = CreateObject("roAssociativeArray")
photo.http=http
photo.xml=xml
photo.owner=owner
photo.GetTitle=function():return m.xml@title:end function
photo.GetID=function():return m.xml@id:end function
photo.GetOwner=pGetOwner
photo.GetURL=pGetURL
return photo
End Function

Function pGetOwner() As String

if m.owner<>invalid return m.owner

return m.xml@owner

End Function

Function pGetURL() As String

a=m.xml.GetAttributes()

url="http://farm"+a.farm+".static.flickr.com/"+a.server+"/"+a.id+"_"+a.se

cret+".jpg"

return url

End Function

Advertising