动态加载FLASH新闻(xml)

来源:互联网 发布:linux论坛 编辑:程序博客网 时间:2024/05/22 05:09

通过调用XML来输出FLASH图片新闻~

flash当然要下载一个..

自己找吧~

只提供一个方法,类似JAVASCRIPT~

    public void abc()
        
{            
            
            XmlDocument doc 
= new XmlDocument();
            doc.Load(
this.MapPath("news.xml"));
            XmlNodeList nodes 
= doc.SelectSingleNode("news").ChildNodes;
            
string pics=null;
            
string links=null;
            
string texts=null;
            
foreach(XmlNode xn in nodes)
            
{
                XmlElement xmlele 
=(XmlElement)xn;
                pics 
+=xmlele.GetAttribute("pic")+"|";
                links 
+=xmlele.GetAttribute("url")+"|";
                texts 
+=xmlele.InnerText+"|";
            }

            pics 
=pics.Remove(pics.Length-1,1); 
            links 
=links.Remove(links.Length-1,1); 
            texts 
=texts.Remove(texts.Length-1,1); 
            
int focus_width=255;
            
int focus_height=120;
            
int text_height=30;
            
int swf_height = focus_height+text_height;                
            System.Text.StringBuilder abc 
= new System.Text.StringBuilder();
            abc.Append(
"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='"+ focus_width +"' height='"+ swf_height +"' >");
            abc.Append(
"<param name='allowScriptAccess' value='sameDomain'><param name='movie' value='images/news.swf'><param name=wmode value=transparent><param name='quality' value='high'>");
            abc.Append(
"<param name='menu' value='false'><param name=wmode value='opaque'>");
            abc.Append(
"<param name='FlashVars' value='pics="+pics+"&links="+links+"&texts="+texts+"&borderwidth="+focus_width+"&borderheight="+focus_height+"&textheight="+text_height+"' >");
            abc.Append(
"<embed src='images/playswf.swf' wmode='opaque' FlashVars='pics="+pics+"&links="+links+"&texts="+texts+"&borderwidth="+focus_width+"&borderheight="+focus_height+"&textheight="+text_height+"' menu='false' bgcolor='#cccccc' quality='high' width='"+ focus_width +"' height='"+ swf_height +"' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
            abc.Append(
"</object>");            
            Response.Write(abc.ToString().Replace(
"'","""));    

        }