2010七月24
完美支持中文wp-cumulus标签云插件源码(无锯齿无抖动7K大小)
1、首先安装wp-cumulus 标签Tag Cloud插件
这个不用教了吧?:)啰嗦一下:
参数:
wp_tag_cloud parameters:smallest=8&largest=22&number=45
设置最小字体、最大字体、总数量
应用:
若网站主题不能自动支持,可以手动编辑php文件,加入 <?php wp_cumulus_insert(); ?> 代码。
2、使用说明
鼠标右击下面链接,选择“另存为”(仅7K大小,效果见本站首页右下):
/wp-content/plugins/wp-cumulus/tagcloud.swf
上传替换网站 /wp-content/plugins/wp-cumulus/ 下tagcloud.swf文件,即可完美支持中文。
——以下是开发者阅读,普通用户可以略过————————————————————
3、修改wp-cumulus源代码
安装Adobe Flash CS4 后打开wp-cumulus源文件,按照上图步骤,选择“tag”文本框,不嵌入字符。
4、修改Tag.as
打开 C:\wp-cumulus\flash sources\com\roytanck\wpcumulus\Tag.as
源代码:
package com.roytanck.wpcumulus { import flash.geom.ColorTransform; import flash.filters.*; import flash.display.*; import flash.events.*; import flash.net.*; import flash.text.*; public class Tag extends Sprite { private var _back:Sprite; private var _node:XML; private var _cx:Number; private var _cy:Number; private var _cz:Number; private var _color:Number; private var _hicolor:Number; private var _active:Boolean; private var _tf:TextField; public function Tag( node:XML, color:Number, hicolor:Number ){ _node = node; _color = color; _hicolor = hicolor; _active = false; _tf = new TextField(); _tf.autoSize = TextFieldAutoSize.LEFT; _tf.selectable = false; _tf.antiAliasType = AntiAliasType.ADVANCED; var format:TextFormat = new TextFormat(); format.font = "微软雅黑, Arial, 黑体";//设置字体 format.bold = true; format.color = color; format.size = 16 * getNumberFromString(node["@style"]); _tf.defaultTextFormat = format; //_tf.embedFonts = true; //是否使用字符库,这个肯定要注释掉 _tf.text = node; var _loc_5:BlurFilter = new BlurFilter(5, 5, 1); _tf.filters = [_loc_5]; var _loc_6:Bitmap = new Bitmap(null, "auto", true); var _loc_7:BitmapData = new BitmapData(_tf.width, _tf.height, true, color); _loc_7.draw(_tf); _loc_6.bitmapData = _loc_7; _loc_6.scaleY = 0.15; _loc_6.scaleX = 0.15; addChild(_loc_6); _loc_6.x = (-this.width) / 2; _loc_6.y = (-this.height) / 2; _back = new Sprite(); _back.graphics.beginFill(_hicolor, 0); _back.graphics.lineStyle(0.6, _hicolor); _back.graphics.drawRect(0, 0, _loc_6.width, _loc_6.height); _back.graphics.endFill(); addChildAt(_back, 0); _back.x = (-_loc_6.width) / 2; _back.y = (-_loc_6.height) / 2; _back.visible = false; if( _node["@href"].substr(0,4).toLowerCase() == "http" ){ this.mouseChildren = false; this.buttonMode = true; this.useHandCursor = true; this.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); this.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); this.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } } private function mouseOverHandler( e:MouseEvent ):void { _back.visible = true; _tf.textColor = _hicolor; _active = true; } private function mouseOutHandler( e:MouseEvent ):void { _back.visible = false; _tf.textColor = _color; _active = false; } private function mouseUpHandler( e:MouseEvent ):void { var request:URLRequest = new URLRequest( _node["@href"] ); var target:String = _node["@target"] == undefined ? "_self" : _node["@target"]; navigateToURL( request, target ); } private function getNumberFromString( s:String ):Number { return( Number( s.match( /(\d|\.|\,)/g ).join("").split(",").join(".") ) ); } public function set cx( n:Number ){ _cx = n } public function get cx():Number { return _cx; } public function set cy( n:Number ){ _cy = n } public function get cy():Number { return _cy; } public function set cz( n:Number ){ _cz = n } public function get cz():Number { return _cz; } public function get active():Boolean { return _active; } } }
5、源代码下载
由于本空间不支持rar文件,所以有兴趣的可以到我的CSDN地址下载:
http://download.csdn.net/source/2571076
6、说明
花了一天的时间,查找了许多资料,先是官方的不支持中文,后来找到方法支持中文但是有抖动的现象,效果不好,再后来找到无抖动的swf文件,但是不开源,于是自己琢磨。。
请保留本站链接,咱都不收费而且开源了,是吧?。。呵呵
把一些注释、空格、再优化下代码,swf文件还可以压缩,这个需要你自己尝试了。。。