Fork me on GitHub

标签 tagcloud 下的文章

tagcloud的使用

tagcloud一共两个文件

  1. tagcloud.swf:是标签云显示的主flash程序
  2. swfobject.js: flash的控制程序
    下载地址:[[csdn]][1]

有两种使用方式,第一种是通过在网页上使用函数实时生成标签云的标签;第二种是通过将标签写入xml文件,flash读取xml文件显示标签云

基础

参考Demo程序3DTagCloudWithoutXML,在网页文件里的<head>标签中加入swfobject.js的引用

<head>
<title>3D Tag Cloud without XML example</title>
<meta http-equiv="Content-Type" content="text/html" />
<!-- SWFObject embed by Geoff Stearns geoff@deconcept.com http://blog.deconcept.com/swfobject/ -->
<script type="text/javascript" src="swfobject.js"></script>
<style type="text/css">
    body { background-color: #eee; padding: 20px; }
</style>
</head>

方式一

在网页<body>标签中插入以下代码

<body>
    <div id="flashcontent">This will be shown to users with no Flash or Javascript.</div>
    <script type="text/javascript">

              var so = new SWFObject("tagcloud.swf", "tagcloud", "600", "400", "7", "#ffffff");

              // uncomment next line to enable transparency

              so.addParam("wmode", "transparent");

              so.addVariable("tcolor", "0x333333");

              so.addVariable("mode", "tags");

              so.addVariable("distr", "true");

              so.addVariable("tspeed", "100");

              so.addVariable("tagcloud", "<tags><a  href='http://www.google.com' style='22' color='0xff0000'  hicolor='0x00cc00'>Google</a><a href='http://www.baidu.com'  style='12'>Baidu</a><a href='http://www.sina.com.cn'  style='16'>Sina</a><a href='http://www.apple.com.cn'  style='14'>Apple</a><a href='http://wsi.gucas.ac.cn'  style='12'>WSI</a><a href='http://www.bit.edu.cn'  style='12'>BIT</a><a href='http://www.sony.com.cn'  style='9'>SONY</a><a href='http://www.gucas.ac.cn'  style='10'>GUCAS</a><a href='http://www.sohu.com.cn'  style='10'>Sohu</a><a href='http://www.renren.com'  style='12'>renren</a><a href='http://www.qq.com'  style='12'>QQ</a></tags>");

              so.write("flashcontent");

    </script>
</body>

方式二

在网页<body>标签中插入以下代码

<body>
  <div id="flashcontent">This will be shown to users with no Flash or Javascript.</div>
  <script type="text/javascript">
           var so = new SWFObject("tagcloud.swf", "tagcloud", "600", "400", "7", "#ffffff");
           // uncomment next line to enable transparency
           so.addParam("wmode", "transparent");
           so.addVariable("tcolor", "0x333333");
           so.addVariable("tcolor2", "0x009900");
           so.addVariable("hicolor", "0x000000");
           so.addVariable("tspeed", "100");
           so.addVariable("distr", "true");
           so.addVariable("xmlpath", "tagcloud.xml");
           so.write("flashcontent");
  </script>
 </body>