home *** CD-ROM | disk | FTP | other *** search
- property xmlData, xmlStatus, listData, flashObj, sectionsPage, currentBanner
- global dataSource, handlerStore
-
- on new me, xmlSource, flashRef
- initialise()
- contentFile = getVolume() & xmlSource
- if fileExists(contentFile) then
- me.xmlData = new(script("xml.parser"))
- me.xmlData.ignoreWhitespace(1)
- me.xmlStatus = me.xmlData.parseUrl(contentFile)
- else
- put "file doesn't exist"
- end if
- if integerp(flashRef) then
- flashObj = flashRef
- else
- put "flash reference was not an integer/sprite number"
- end if
- return me
- end
-
- on initialise me
- xmlData = VOID
- xmlStatus = VOID
- listData = VOID
- end
-
- on getStatus me
- if xmlData.doneParsing() then
- if xmlData.getError() = EMPTY then
- statusVal = 1
- else
- statusVal = -1
- put xmlData.getError()
- end if
- else
- statusVal = 0
- end if
- return [#status: statusVal, #parsed: xmlData.doneParsing(), #error: xmlData.getError()]
- end
-
- on bannerPressed me
- flashSecNum = sprite("Content pane").sections.selectedIndex + 1
- bannerNode = me.findBanner(integer(flashSecNum))
- launch(unescapePath(bannerNode.attributeValue["href"]))
- end
-
- on findSection me, selIndex
- correctedIndex = selIndex + 1
- actualNumPages = xmlData["disc"]["pages"].child.count + xmlData["disc"]["sections"].child.count - 1
- numSections = xmlData["disc"]["sections"].child.count
- endSections = sectionsPage + numSections - 1
- if correctedIndex < sectionsPage then
- return xmlData["disc"]["pages"].child[selIndex + 1]
- else
- if correctedIndex > endSections then
- actualPageNum = correctedIndex - numSections + 1
- return xmlData["disc"]["pages"].child[actualPageNum]
- else
- actualSectionNum = correctedIndex - sectionsPage + 1
- return xmlData["disc"]["sections"].child[actualSectionNum]
- end if
- end if
- end
-
- on findBanner me, secNum
- actualNumPages = xmlData["disc"]["pages"].child.count + xmlData["disc"]["sections"].child.count - 1
- numSections = xmlData["disc"]["sections"].child.count
- endSections = sectionsPage + numSections - 1
- if secNum < sectionsPage then
- return xmlData["disc"]["pages"].child[secNum]["banner"]
- else
- if secNum > endSections then
- actualPageNum = secNum - endSections + 2
- return xmlData["disc"]["pages"].child[actualPageNum]["banner"]
- else
- actualSectionNum = secNum - sectionsPage + 1
- return xmlData["disc"]["sections"].child[actualSectionNum]["banner"]
- end if
- end if
- end
-
- on disableHeaderBar me, secNum
- secNode = me.findSection(secNum)
- disabledBarColour = secNode["colours"]["row"].attributeValue["disabled"]
- sprite("Header bar").color = strToRGB(disabledBarColour)
- end
-
- on setBarColours me, secNum
- secNode = me.findSection(secNum)
- sectionColours = [#rowBase: secNode["colours"]["row"].attributeValue["base"], #rowRollOver: secNode["colours"]["row"].attributeValue["rollover"], #rowSelected: secNode["colours"]["row"].attributeValue["selected"], #rowDisabled: secNode["colours"]["row"].attributeValue["disabled"], #textBase: secNode["colours"]["text"].attributeValue["base"], #textRollOver: secNode["colours"]["text"].attributeValue["rollover"], #textSelected: secNode["colours"]["text"].attributeValue["selected"], #textDisabled: secNode["colours"]["text"].attributeValue["disabled"]]
- sprite("Content pane").setListBarColour(sectionColours[#rowBase])
- sprite("Footer bar2").setBarColour("normal", sectionColours[#rowBase])
- sprite("Footer bar2").setBarColour("rollOver", sectionColours[#rowRollOver])
- sprite("Footer bar2").setBarColour("selection", sectionColours[#rowSelected])
- sprite("Footer bar2").setBarColour("disabled", sectionColours[#rowDisabled])
- sprite("Footer bar2").setBarColour("textNormal", sectionColours[#textBase])
- sprite("Footer bar2").setBarColour("textRollOver", sectionColours[#textRollOver])
- sprite("Footer bar2").setBarColour("textSelection", sectionColours[#textSelected])
- sprite("Footer bar2").setBarColour("textDisabled", sectionColours[#textDisabled])
- sprite("Footer bar2").applyColours()
- sprite("Fake footer").visible = 0
- end
-
- on setBanner me, secNum
- actualNumPages = xmlData["disc"]["pages"].child.count + xmlData["disc"]["sections"].child.count - 1
- numSections = xmlData["disc"]["sections"].child.count
- endSections = sectionsPage + numSections - 1
- bannerNode = me.findBanner(secNum)
- bannerSrc = bannerNode.attributeValue["src"]
- bannerTarget = bannerNode.attributeValue["href"]
- borderVis = bannerNode.attributeValue["border"]
- if borderVis = "true" then
- sprite("Banner border").visible = 1
- else
- sprite("Banner border").visible = 0
- end if
- bannerType = getBannerType(bannerSrc)
- case bannerType of
- #animGif:
- member("banner_gif").fileName = getVolume() & unescapePath(bannerSrc)
- sprite("Banner placeholder").member = member("banner_gif")
- #flash:
- member("banner_swf").fileName = getVolume() & unescapePath(bannerSrc)
- member("banner_swf").scaleMode = #noScale
- sprite("Banner placeholder").member = member("banner_swf")
- sprite("Banner placeholder").directToStage = 1
- end case
- end
-
- on setColours secNum, secNode
- if secNode["colours"]["row"] <> VOID then
- rowColour = secNode["colours"]["row"].attributeValue["base"]
- if rowColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "normal", rowColour)
- else
- sprite("Content pane").setSectionColour(secNum, "normal", "192,192,192")
- end if
- rowColour = secNode["colours"]["row"].attributeValue["rollover"]
- if rowColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "rollOver", rowColour)
- else
- sprite("Content pane").setSectionColour(secNum, "rollOver", "144,144,144")
- end if
- rowColour = secNode["colours"]["row"].attributeValue["selected"]
- if rowColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "selection", rowColour)
- else
- sprite("Content pane").setSectionColour(secNum, "selection", "160,160,160")
- end if
- rowColour = secNode["colours"]["row"].attributeValue["disabled"]
- if rowColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "disabled", rowColour)
- else
- sprite("Content pane").setSectionColour(secNum, "disabled", "220,220,220")
- end if
- else
- sprite("Content pane").setSectionColour(secNum, "normal", "192,192,192")
- sprite("Content pane").setSectionColour(secNum, "rollOver", "144,144,144")
- sprite("Content pane").setSectionColour(secNum, "selection", "160,160,160")
- sprite("Content pane").setSectionColour(secNum, "disabled", "220,220,220")
- end if
- if secNode["colours"]["text"] <> VOID then
- textColour = secNode["colours"]["text"].attributeValue["base"]
- if textColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "textNormal", textColour)
- else
- sprite("Content pane").setSectionColour(secNum, "textNormal", "144,144,144")
- end if
- textColour = secNode["colours"]["text"].attributeValue["rollover"]
- if textColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "textRollOver", textColour)
- else
- sprite("Content pane").setSectionColour(secNum, "textRollOver", "144,144,144")
- end if
- textColour = secNode["colours"]["text"].attributeValue["selected"]
- if textColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "textSelection", textColour)
- else
- sprite("Content pane").setSectionColour(secNum, "textSelection", "96,96,96")
- end if
- textColour = secNode["colours"]["text"].attributeValue["disabled"]
- if textColour <> VOID then
- sprite("Content pane").setSectionColour(secNum, "textDisabled", textColour)
- else
- sprite("Content pane").setSectionColour(secNum, "textDisabled", "192,192,192")
- end if
- else
- sprite("Content pane").setSectionColour(secNum, "textNormal", "144,144,144")
- sprite("Content pane").setSectionColour(secNum, "textRollOver", "144,144,144")
- sprite("Content pane").setSectionColour(secNum, "textSelection", "96,96,96")
- sprite("Content pane").setSectionColour(secNum, "textDisabled", "192,192,192")
- end if
- end
-
- on setContent
- numPages = xmlData["disc"]["pages"].child.count
- numSections = xmlData["disc"]["sections"].child.count
- if numPages > 1 then
- repeat with pageNum = 1 to numPages
- if xmlData["disc"]["pages"].child[pageNum].attributeValue["name"] = "sections" then
- sectionsPage = pageNum
- end if
- end repeat
- if sectionsPage <> 1 then
- numPreceding = sectionsPage - 1
- repeat with pageNum = 1 to numPreceding
- currentPage = xmlData["disc"]["pages"].child[pageNum]
- sprite("Content pane").setSection(currentPage.attributeValue["name"])
- if currentPage.attributeValue["headline"] <> VOID then
- sprite("Content pane").setSectionAttribute(pageNum, "headline", currentPage.attributeValue["headline"])
- end if
- introDesc = currentPage["body"].attributeValue["text"]
- if introDesc.char[1] = "<" then
- sprite("Content pane").setSectionAttribute(pageNum, "maindesc", introDesc)
- else
- sprite("Content pane").setSectionAttribute(pageNum, "maindesc", "<pagebody>" & introDesc & "</pagebody>")
- end if
- setColours(pageNum, currentPage)
- end repeat
- end if
- setSections(sectionsPage)
- if sectionsPage < numPages then
- sectionsOffset = 1
- repeat with pageNum = sectionsPage + 1 to numPages
- currentPage = xmlData["disc"]["pages"].child[pageNum]
- sprite("Content pane").setSection(xmlData["disc"]["pages"].child[pageNum].attributeValue["name"])
- mainDescText = currentPage["body"].attributeValue["text"]
- if mainDescText.char[1] = "<" then
- sprite("Content pane").setSectionAttribute(numPreceding + numSections + sectionsOffset, "maindesc", mainDescText)
- else
- sprite("Content pane").setSectionAttribute(numPreceding + numSections + sectionsOffset, "maindesc", "<pagebody>" & mainDescText & "</pagebody>")
- end if
- setColours(pageNum, currentPage)
- sectionsOffset = sectionsOffset + 1
- end repeat
- end if
- else
- sectionsPage = 1
- setSections(sectionsPage)
- end if
- repeat with sectionNum = 1 to numSections
- currentSection = xmlData["disc"]["sections"].child[sectionNum]
- actualSectionNum = sectionsPage + sectionNum - 1
- if currentSection["intro"] <> VOID then
- mainDescText = currentSection["intro"]["main"].attributeValue["text"]
- if mainDescText.char[1] = "<" then
- sprite("Content pane").setSectionAttribute(actualSectionNum, "maindesc", mainDescText)
- else
- sprite("Content pane").setSectionAttribute(actualSectionNum, "maindesc", "<pagedesc>" & mainDescText & "</pagedesc>")
- end if
- if currentSection["intro"]["footer"] <> VOID then
- footerDescText = currentSection["intro"]["footer"].attributeValue["text"]
- if footerDescText.char[1] = "<" then
- sprite("Content pane").setSectionAttribute(actualSectionNum, "footerdesc", footerDescText)
- else
- sprite("Content pane").setSectionAttribute(actualSectionNum, "footerdesc", "<pagedesc>" & footerDescText & "</pagedesc>")
- end if
- end if
- end if
- numEntries = currentSection["entries"].child.count
- repeat with entryNum = 1 to numEntries
- currentEntry = currentSection["entries"].child[entryNum]
- if currentEntry.attributeValue["shorttitle"] <> VOID then
- listTitle = currentEntry.attributeValue["shorttitle"]
- fullTitle = currentEntry.attributeValue["title"]
- sprite("Content pane").setApp(actualSectionNum, listTitle, fullTitle)
- else
- sprite("Content pane").setApp(actualSectionNum, currentEntry.attributeValue["title"])
- end if
- descText = currentEntry["description"].attributeValue["text"]
- sprite("Content pane").setAppAttribute(actualSectionNum, entryNum, "description", descText)
- numLinks = currentEntry["links"].child.count
- repeat with linkNum = 1 to numLinks
- setLink(actualSectionNum, entryNum, linkNum, currentEntry["links"].child[linkNum])
- end repeat
- if currentEntry["footer"] <> VOID then
- column1Title = VOID
- column1Text = VOID
- column2Title = VOID
- column2Text = VOID
- if currentEntry["footer"]["column1"] <> VOID then
- currentColumn = currentEntry["footer"]["column1"]
- column1Title = "<columnboldwhite>" & currentColumn.attributeValue["name"] & "</columnboldwhite>"
- column1Text = "<column>" & currentColumn.child[1].attributeValue["text"]
- numRows = currentColumn.child.count
- if numRows > 1 then
- repeat with rowNum = 2 to currentColumn.child.count
- rowText = currentColumn.child[rowNum].attributeValue["text"]
- column1Text = column1Text & "
" & rowText
- end repeat
- end if
- column1Texlt = column1Text & "</column>"
- sprite("Content pane").setAppAttribute(actualSectionNum, entryNum, "column1", column1Text)
- sprite("Content pane").setAppAttribute(actualSectionNum, entryNum, "column1Title", column1Title)
- sprite("Content pane").setAppAttribute(actualSectionNum, entryNum, "column1Groups", currentColumn.child.count)
- end if
- if currentEntry["footer"]["column2"] <> VOID then
- currentColumn = currentEntry["footer"]["column2"]
- column2Title = "<columnboldwhite>" & currentColumn.attributeValue["name"] & "</columnboldwhite>"
- column2Text = "<column>" & currentColumn.child[1].attributeValue["text"]
- numRows = currentColumn.child.count
- if numRows > 1 then
- repeat with rowNum = 2 to currentColumn.child.count
- rowText = currentColumn.child[rowNum].attributeValue["text"]
- column2Text = column2Text & "
" & rowText
- end repeat
- end if
- column2Text = column2Text & "</column>"
- sprite("Content pane").setAppAttribute(actualSectionNum, entryNum, "column2", column2Text)
- sprite("Content pane").setAppAttribute(actualSectionNum, entryNum, "column2Title", column2Title)
- sprite("Content pane").setAppAttribute(actualSectionNum, entryNum, "column2Groups", currentColumn.child.count)
- end if
- end if
- end repeat
- end repeat
- if xmlData["disc"]["footer"] <> VOID then
- numFooterPages = xmlData["disc"]["footer"].child.count
- footerPages = xmlData["disc"]["footer"]
- repeat with footerPage = 1 to numFooterPages
- if footerPages.child[footerPage].attributeValue["text"] <> VOID then
- sprite("Content pane").setFooterPage(footerPages.child[footerPage].attributeValue["name"], footerPages.child[footerPage].attributeValue["text"])
- next repeat
- end if
- if footerPages.child[footerPage].attributeValue["href"] <> VOID then
- sprite("Content pane").setFooterPage(footerPages.child[footerPage].attributeValue["name"], footerPages.child[footerPage].attributeValue["href"])
- end if
- end repeat
- end if
- sprite("Content pane").contentDone()
- end
-
- on showFooterPage me, pageNum
- if pageNum = 5 then
- dataSource.setBanner(1)
- sprite("Content pane").showCredits()
- else
- if xmlData["disc"]["footer"] <> VOID then
- if pageNum <> 1 then
- dataSource.setBanner(1)
- end if
- footerPage = xmlData["disc"]["footer"].child[pageNum]
- pageTitle = footerPage.attributeValue["name"]
- if footerPage.attributeValue["text"] <> VOID then
- sprite("Content pane").showPage(pageTitle, footerPage.attributeValue["text"])
- else
- if footerPage.attributeValue["href"] <> VOID then
- launch(unescapePath(footerPage.attributeValue["href"]))
- else
- pageText = "Page not recognised"
- end if
- end if
- end if
- end if
- end
-
- on setSections sectionsPage
- numSections = xmlData["disc"]["sections"].child.count
- repeat with pageNum = 1 to numSections
- currentSection = xmlData["disc"]["sections"].child[pageNum]
- sprite("Content pane").setSection(currentSection.attributeValue["name"])
- if currentSection["intro"] <> VOID then
- setSectionIntro(sectionsPage + pageNum - 1, currentSection)
- end if
- setColours(sectionsPage + pageNum - 1, currentSection)
- end repeat
- end
-
- on setSectionIntro secNum, section
- if section.attributeValue["shorttitle"] <> VOID then
- shortTitle = section.attributeValue["shorttitle"]
- end if
- introDesc = removeOuterTags(section["intro"]["main"].toString())
- if section["intro"]["footer"] <> VOID then
- footerDesc = removeOuterTags(section["intro"]["footer"].toString())
- else
- footerDesc = VOID
- end if
- highlights = findNodesWithAttr(section["entries"], "highlight", "true")
- if highlights.count <> 0 then
- setHighlights(secNum, highlights)
- end if
- updates = findNodesWithAttr(section["entries"], "updated", "true")
- if updates.count <> 0 then
- setUpdates(secNum, updates)
- end if
- end
-
- on setHighlights secNum, highlights
- repeat with hlNum = 1 to highlights.count
- if highlights[hlNum].node.attributeValue["shorttitle"] <> VOID then
- hlTitle = highlights[hlNum].node.attributeValue["shorttitle"]
- else
- hlTitle = highlights[hlNum].node.attributeValue["title"]
- end if
- if highlights[hlNum].node["highlight"] <> VOID then
- hlDesc = highlights[hlNum].node["highlight"].attributeValue["text"]
- if highlights[hlNum].node["highlight"].attributeValue["image"] <> VOID then
- hlImage = getVolume() & "\" & highlights[hlNum].node["highlight"].attributeValue["image"]
- else
- hlImage = "undefined"
- end if
- else
- hlDesc = "ERROR: A highlight description was not provided for this item."
- hlImage = "none"
- end if
- sprite("Content pane").setHighlight(secNum, hlNum, hlTitle, hlDesc, highlights[hlNum].childNum, hlImage)
- end repeat
- end
-
- on setUpdates secNum, updates
- repeat with updNum = 1 to updates.count
- sprite("Content pane").setUpdate(secNum, updates[updNum].childNum, updates[updNum].node.attributeValue["title"])
- end repeat
- end
-
- on findNodesWithAttr parentNode, attrName, attrValue
- matchingNodes = []
- repeat with childNum = 1 to parentNode.child.count
- currentNode = parentNode.child[childNum]
- if currentNode.attributeValue[attrName] = attrValue then
- matchingNodes.add([#node: currentNode, #childNum: childNum])
- end if
- end repeat
- return matchingNodes
- end
-
- on assembleHTMLText parentNode
- htmlText = EMPTY
- repeat with childNum = 1 to parentNode.child.count
- htmlText = htmlText & parentNode.child[childNum].toString()
- end repeat
- return htmlText
- end
-
- on removeOuterTags xmlString
- tagLength = offset(">", xmlString)
- returnStr = xmlString.char[tagLength + 1..xmlString.length - tagLength - 1]
- return returnStr
- end
-
- on setLink sectionNum, entryNum, linkNum, currentLink
- if currentLink.child.count <> 0 then
- sprite("Content pane").setComplexLink(sectionNum, entryNum, linkNum, currentLink.attributeValue["label"])
- else
- sprite("Content pane").setSimpleLink(sectionNum, entryNum, currentLink.attributeValue["label"], currentLink.attributeValue["href"])
- end if
- end
-