bullet proof hosting

 

 
offshore hosting
 
 
Article HOME | BP Hosting | Bulk Mail & Hosting News | Script
 
Script>ASP Script>

How to display RSS/XML news feed in Flash movie by means of ASP/ASP.NET script using ASP and SWF Scout library

  Date:2006-07-19 13 Author:bp server Origin:BP-Server.com

This page provides information on free script that generates creeping line like Flash movie displaying news from remote RSS feed using SWF Scout library and ASP.

This script can be used free of charge on any ASP or ASP.NET web-server and generate Flash movie from RSS feed. To generate Flash movie that displays RSS/XML feed you have to have SWF Scout library installed on you ASP/ASP.NET web-server

RSS2flash.ASP script:

<%
 Response.Expires = -1
 
 ' =========== RSS2Flash.ASP for ASP/ASP.NET ==========
 ' copyright 2005 (c) www.Bytescout.com
 ' ===============================================
 
 ' =========== configuration =====================
 ' ##### URL to RSS Feed to display #########
 URLToRSS = "http://rssnewsapps.ziffdavis.com/tech.xml"
 
 ' ##### max number of displayed items per RSS #####
 MaxNumberOfItems = 10
 
 ' ##### text align, available values are: center, left, right
 FlashTextAlign = "left"
 FlashTextColor = "#000000"
 FlashLinkColor = "#0000FF"
 FlashFontSize = 10
 FlashFontName = "Arial"
 
 FlashWidth = 300 ' width
 FlashHeight = 600 ' height
 FlashStartOffset = 100 ' offset for initial show
 
 FlashFramesPerSecond = 10
 
 ' ##### Main template constants
 MainTemplateHeader = ""
 MainTemplateFooter = ""
 ' ##### Item template.
 ' ##### will be replaced with item link
 ' ##### will be replaced with item title
 ' ##### will be replaced with item description
 ItemTemplate = "<P align='" & FlashTextAlign & "'><a href=" & """""" & " target='_blank'><font COLOR='" & FlashLinkColor & "'></font></a></P><P></P><P align='" & FlashTextAlign & "'><font color='" & FlashTextColor & "'></font></p><P></P>"
 

 

 

 ' ##### Error message that will be displayed if not items etc
 ErrorMessage = "Error has occured while trying to process <a href='" & URLToRSS & "'>" & URLToRSS & "</a><BR>Please contact web-master"
 
 ' ================================================
 
 Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
 xmlHttp.Open "Get", URLToRSS, false
 xmlHttp.Send()
 RSSXML = xmlHttp.ResponseText
 
 Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
 xmlDOM.async = false
 xmlDOM.LoadXml(RSSXML)
 
 Set xmlHttp = Nothing ' clear HTTP object
 
 Set RSSItems = xmlDOM.getElementsByTagName("item") ' collect all "item" from downloaded RSS
 Set xmlDOM = Nothing ' clear XML
 
 RSSItemsCount = RSSItems.Length-1
 
 ' writing Header
 if RSSItemsCount > 0 then 
  RSSHTMLText = MainTemplateHeader
 Else
  RSSHTMLText = ""
 End If
 
 RSSItemsDisplayedCounter = -1
 
 For i = 0 To RSSItemsCount
 Set RSSItem = RSSItems.Item(i)
 
  for each child in RSSItem.childNodes
   Select case lcase(child.nodeName)
     case "title"
           RSStitle = child.text
     case "link"
           RSSlink = child.text
     case "description"
           RSSdescription = child.text
   End Select
  next
 
  RSSItemsDisplayedCounter = RSSItemsDisplayedCounter+1
 
  if J<MaxNumberOfItems then 
  ItemContent = Replace(ItemTemplate,"",RSSlink)
  ItemContent = Replace(ItemContent,"",RSSTitle)
  RSSHTMLText = RSSHTMLText+ Replace(ItemContent,"",RSSDescription)
  ItemContent = ""
  End if
 
 Next
 
 ' writing Footer
 if RSSItemsCount > 0 then 
  RSSHTMLText = RSSHTMLText+ MainTemplateFooter
 else 
  RSSHTMLText = RSSHTMLText+ ErrorMessage
 End If
 
 Set Movie = Server.CreateObject("SWFScout.FlashMovie")
 Movie.InitLibrary "demo", "demo"
 Movie.BeginMovie 0, 0, FlashWidth, FlashHeight, 1, FlashFramesPerSecond, 6
 Movie.Compressed = true
 Movie.GenerateInMemoryFile = True
 Movie.SetBackgroundColor 255, 255, 255 ' set background color to white
 
 Font = Movie.AddFont(FlashFontName, 10, False, False, False, true, 0) ' add font
 Movie.FONT_IsDynamicText = true
 Movie.FONT_AddChars 5
 
 Movie.AddFont FlashFontName, FlashFontSize, True, False, False, true, 0 ' add font
 Movie.FONT_IsDynamicText = true
 Movie.FONT_AddChars 5
 
' create and place text
 
 if RSSItemsDisplayedCounter>0 then 
 KLen = Len(RSSHTMLText)
 k = FlashFontSize * 1.1
 k = FlashWidth / k ' number of chars we have in each line
 k = KLen / k ' number of lines we have in text
 k = FlashFontSize*(k+ RSSItemsDisplayedCounter*2)  ' add 2 empty strings for each RSS item (see RSSItemsDisplayedCounter variable above)
 else
 K= FlashHeight
 End If
 
 Text = Movie.AddTextEdit("RSSText",RSSHTMLText,200, 200, 200, 255, Font, 0,FlashStartOffset,FlashWidth,K)
 
 Movie.TEXT_UseOutlines = true
 Movie.TEXT_NoSelect = true
 Movie.TEXT_MultiLine = true
 Movie.TEXT_WordWrap = true
' Movie.TEXT_Border = false
 Movie.TEXT_IsHTML = true
 
 Movie.TEXT_ReadOnly = true
 
 DepthUsed = Movie.CurrentMaxDepth ' place text into current depth
 
 Movie.PlaceText Text, DepthUsed
 
 if RSSItemsDisplayedCounter>0 then
 for i = 0 to K+FlashStartOffset step 2
  Movie.PlaceText Text, DepthUsed
  Movie.PLACE_SetTranslate 0,-i
  Movie.PLACE_AutoRemoveDepth= true
  Movie.ShowFrame(1)
 Next
 else
  Movie.ShowFrame(1)
 end If
 
 Movie.EndMovie ' end movie generation
 
 ' get generated SWF as binary image
 SWFImage = Movie.BinaryImage
 ' clear the output stream
 
 response.Clear
 
 ' set the content type to SWF
 
 response.ContentType = "application/x-shockwave-flash"
 
 ' add content type header 
 response.AddHeader "Content-Type", "application/x-shockwave-flash"
 
 ' set the content disposition
 response.AddHeader "Content-Disposition", "inline;filename=rssflash.swf"
 
 ' write the binary image to the Response output stream 
 response.BinaryWrite SWFImage
 
 response.End
 
 ' disconnect from library
 Set Movie = Nothing
%>
Next Page:  
article add :frenzy
 
 
 
Copyright © 2002-2008 DISKHOSTING All Rights Reserved | Home | BP Hosting Plan | BP Server | BP URL | Article1 2 | Sitemap |