3D 标签云 Flash 的使用

3D 标签云的使用

3D标签云包含两个必须文件,源文件在这下载

http://download.csdn.net/source/2037774

 

1.       tagcloud.swf:是标签云显示的主flash程序

2.       swfobject.js:  flash的控制程序

有两种使用方式,第一种是通过在网页上使用函数实时生成标签云的标签;第二种是通过将标签写入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>标签中插入以下代码就能显示3D 标签云

<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>

 

方法二、在<head>中插入swfobject.js与方法一相同

<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>

 

                       下面是具体函数的解释

 

1.  SWFObject(swf, id, width, height, version, background-color [, quality, xiRedirectUrl, redirectUrl, detectKey]);

初始化对象

 

各参数解释如下

  • swf – 你的swf文件的名字和路径.
  • id – 生成对象的ID.
  • width –Flash的宽度.
  • height – Flash的高度.
  • version – 需要Flash播放器的版本,格式如下 ‘majorVersion.minorVersion.revision’. 例如: "6.0.65". 或者直接用大版本号, 例如 "6".
  • background-color –Flash的背景色.

下面是可选变量:

  • quality –Flash的画质. 如果没有指明, 默认为"high".
  • xiRedirectUrl –如果你要重定向那些完成ExpressInstall 升级的用户, 可以在这里指定URL. If you would like to redirect users who complete the ExpressInstall upgrade, you can specify an alternate URL here
  • redirectUrl – 如果你要重定向那些没有正确安装插件版本的用户,用这个参数重定向. If you wish to redirect users who don’t have the correct plug-in version, use this parameter and they will be redirected.
  • detectKey – This is the url variable name the SWFObject script will look for when bypassing the detection. Default is ‘detectflash’. Example: To bypass the Flash detection and simply write the Flash movie to the page, you could add ?detectflash=false to the url of the document containing the Flash movie.

2.  so.write("flashcontent");

SWFObject脚本把Flash写到页面上

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

设置Flash动画为透明

4.  so.addVariable("parameter", "value");

设置变量的值,变量如下:

Name

Format

Description

mode

String: tags|cats|both

Tells the movie to expect and display tags, categories or both.

distr

String: true|false

设定为true的话,标签会均匀分布在球的表面

tcolor

Hex color value: 0xff0000 for red.

默认的标签颜色

tcolor2

Hex color value

第二标签颜色,标签根据它们的popularity取得两个颜色之间的颜色.

hicolor

Hex color value

鼠标放在标签上的颜色

tspeed

Number: percentage

决定转动的速度. 默认值是100, 数字越大速度越大

tagcloud

XML string (urlencoding optional)

XML 格式设定标签

xmlpath

Path to load the XML from

设定XMLURL, 默认为 ‘tagcloud.xml’

                        

                             XML文件中标签的实例

<tags>

<a href="http://www.roytanck.com/tag/150/" class="tag-link-66" title="2 topics" rel="tag" style="font-size: 20pt;" color="0xff0099">$150</a>

<a href="http://www.roytanck.com/tag/3d/" class="tag-link-39" title="1 topics" rel="tag" style="font-size: 8pt;">3D</a>

<a href="http://www.roytanck.com/tag/api/" class="tag-link-54" title="2 topics" rel="tag" style="font-size: 9.55556pt;">API</a>

<a href="http://www.roytanck.com/tag/wordpress/" class="tag-link-19" title="10 topics" rel="tag" style="font-size: 22pt;" color="0xff0099" hicolor="0x000099">WordPress</a>

</tags>

 

 

                                                   关于标签云对中文的支持

 

 

 在下载的文件里面,有两个swf文件时修改过的flash文件,可以支持中文

 

tagcloud中文简化版.swf 是修改过的支持中文的swf
但是不能更改字体大小

tagcloud中文可改变字体大小抖动.swf
支持中文,可以改变字体大小,运行时抖动,效果不是很好

 

要用的时候直接修改文件名替换原flash文件就行了

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值