仿京东商城图片展示效果(3 位领导批示)

QQ童鞋最近需要京东商城的图片展示效果..可怜的我被拉来当壮丁T_T.. 好久不写JS了.当作练手..

此效果要说也很简单.用到了JQuery的两个插件..
分别为:
内容滚动插件 jcarousel (Project地址: http://sorgalla.com/projects/jcarousel/)
图片放大镜插件 JQZoom (Project地址: http://www.mind-projects.it/projects/jqzoom/)

效果预览:
xxx

全文阅读 »

正则表达式子模式使用函数(1 位领导批示)

原问题地址: http://bbs.blueidea.com/thread-2944055-1-1.html

比较正确的解决方法:

1
2
3
4
5
<?php
$str="[thunder]ftp://3gset.cn:3gset@down.3gset.cn/谢谢你的温柔-S.H.E_飞轮海.mv.320x240.avi[/thunder]";
$str = preg_replace("/\[thunder\](.[^\[]*)\[\/thunder\]/ie","'<a href=\"thunder://'.base64_encode('\\1').'\">\\1</a>'", $str);
echo htmlspecialchars($str);
?>

这段代码的重点是使用了修饰符 e
正则表达式的修饰符 e 是这么解释的:
如果设置这个修饰符, preg_replace() 将在替换值里进行正常的涉及到 的替换, 等同于在 PHP 代码里面一样, 然后用于替换搜索到的字符串.

全文阅读 »

AS3学习之路(6) 简单动画(3 位领导批示)

通过定时器或enterFrame来实现对像的改变和时间联系起来以实现动画.

两个公式需要记忆一下:

(1) 计算弧度 radians = angle * Math.PI / 180
(2) 计算度数 angle = radians * 180 / Math.PI

全文阅读 »

个人常用软件(1 位领导批示)

暂列出本人常用软件. 我主要使用的操作系统有 WINDOWS 7, WINDOWS XP

一、RocketDock

一款模仿APPLE工具栏的软件. 一般重装系统后第一个安装的软件.能使我的桌面干干净净.没有多余图标.

相关网址: http://rocketdock.com/

二、Xlight

Xlight FTP服务器是非常容易使用的FTP服务器. 怎么使用就不用多说了. 自己试试吧.

相关网址: http://www.xlightftpd.com/cn/

全文阅读 »

Tags : ,

PHP创建文件重名.重新命名文件算法(0 位领导批示)

原问题: http://bbs.blueidea.com/thread-2942989-1-1.html

随便写了一个

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
function createFile($filename, $content = '')
{
    $fp = file_put_contents($filename, $content);
}
 
// 要创建的文件名称
$filename = 'www.txt';
 
if(file_exists($filename))
{
    // 打开当前目录
   $handle = opendir('./');
    $fileinfo = pathinfo($filename);
    //print_r($fileinfo);
    $files = array();
    while (false !== ($file = readdir($handle)))
    {
        if(preg_match_all("/{$fileinfo['filename']}(\d*)\.{$fileinfo['extension']}/i", $file, $match))
        {
            $max = max($match[1]);
            if($max)
            {
                $createfile = $fileinfo['filename'] . ($max + 1) . '.' . $fileinfo['extension'];
            }
            else
            {
                $createfile = $fileinfo['filename'] . '1.' . $fileinfo['extension'];
            }
        }
    }
    createFile($createfile);
}
else
{
    createFile($filename);
}
?>

另一种思路..使用临时文件作记数器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
function createFile($filename, $content = '')
{
    if(file_exists($filename . '.tmp'))
    {
        $num = (int) file_get_contents($filename . '.tmp') + 1;
        $fileinfo = pathinfo($filename);
        file_put_contents($fileinfo['filename'] . '(' . $num . ')' .$fileinfo['extension'], $content);
        file_put_contents($filename . '.tmp', $num);
    }
    else
    {
        file_put_contents($filename, $content);
        file_put_contents($filename . '.tmp', 1);
    }
}
createFile('test.txt');
?>

AS3学习之路(5) 拖动对象(0 位领导批示)

一个拖动对象的例子..重点学习的是: startDrag, stopDrag, dropTarget, setChildIndex 等方法的使用

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package
{
	import flash.display.Sprite;
	import flash.display.DisplayObject;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.filters.DropShadowFilter;
 
	public class ClassDrag extends Sprite
	{
		private var _red:Sprite;
		private var _blue:Sprite;
		private var _green:Sprite;
		private var _white:Sprite;
 
		// 被拖动对象原始坐标
		private var _startingLocation:Point;
 
		// 构造函数
		public function ClassDrag()
		{
			init();
		}
 
		// 初始化
		private function init():void
		{
			_red = new Sprite();
			createRectangle(_red, 0xff0000, 10, 10, 20, 20);
			_blue = new Sprite();
			createRectangle(_blue, 0x0000ff, 10, 35, 20, 20);
			_green = new Sprite();
			createRectangle(_green, 0x00cc00, 10, 60, 20, 20);
			_white = new Sprite();
			createRectangle(_white, 0xf0f0f0, 40, 10, 300, 300, false);
		}
 
		// 创建矩型
		private function createRectangle(rectangle:Sprite, color:uint, x:uint, y:uint, width:uint, height:uint, drag:Boolean = true):void
		{
			rectangle.graphics.beginFill(color);
			rectangle.graphics.drawRect(x, y, width, height);
			rectangle.graphics.endFill();
			addChild(rectangle);
 
			if(drag)
			{
				// 侦听事件
				rectangle.addEventListener(MouseEvent.MOUSE_DOWN, pickup);
				rectangle.addEventListener(MouseEvent.MOUSE_UP, place);
			}
		}
 
		// 拖动
		private function pickup(event:MouseEvent):void
		{
			// 保存原始坐标
			_startingLocation = new Point();
			_startingLocation.x = event.target.x;
			_startingLocation.y = event.target.y;
 
			// 开始拖动
			event.target.startDrag();
			// 加上阴影
			event.target.filters = [new DropShadowFilter()];
			// 拖动对象最前显示
			setChildIndex(DisplayObject(event.target), numChildren - 1);
		}
 
		// 拖动结束
		private function place(event:MouseEvent):void
		{
			// 拖动结束
			event.target.stopDrag();
			// 清除阴影
			event.target.filters = null;
 
			// 检测是否已经移动到目标区域
			if(event.target.dropTarget == _white)
			{
				var color:uint;
				switch(event.target)
				{
					case _red: color = 0xff0000; break;
					case _blue: color = 0x0000ff; break;
					case _green: color = 0x00cc00; break;
				}
 
				// 重新创建目标区域
				_white.graphics.clear();
				createRectangle(_white, color, 40, 10, 300, 300, false);
			}
 
			// 拖放对象回到原位
			event.target.x = _startingLocation.x;
			event.target.y = _startingLocation.y;
		}
	}
}
Tags : , ,

[原]WordPress 评论表情插件 silver smilies v0.2 发布(22 位领导批示)

终于有时间更新表情插件了(查看 silver smilies v0.1)

修改了部分方法. 表情直接从目录中读取.所以现在可以方便的增减表情图片了.只需把图片放入face目录即可.不过暂时还不支持中文图片名称.

其它的都很简单.自己看吧^_^

Download

效果预览:

silver_smilies_0_2

AS3学习之路(4) 绘图板示例(0 位领导批示)

很简单的小例子..主要需要掌握的是绘制图形的 drawRect, lineStyle, moveTo, lineTo等方法..鼠标事件侦听的重要性就不再复述.

p.s. cookbook的确是很好的入门书籍.全是实例.^_^

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
 
	public class ClassGraphics extends Sprite
	{
		private var mySprite:Sprite;
 
		// 构造函数
		public function ClassGraphics()
		{
			this.mySprite = new Sprite();
			addChild(this.mySprite);
			this.mySprite.graphics.beginFill(0x336699);
			this.mySprite.graphics.drawRect(0, 0, 550, 400);
			this.mySprite.graphics.endFill();
			this.mySprite.addEventListener(MouseEvent.MOUSE_DOWN, spriteMouseDown);
			this.mySprite.addEventListener(MouseEvent.MOUSE_UP, spriteMouseUp);
		}
 
		// 鼠标按下事件
		private function spriteMouseDown(event:MouseEvent):void
		{
			this.mySprite.graphics.lineStyle(1, 0, 1);
			this.mySprite.graphics.moveTo(mouseX, mouseY);
			this.mySprite.addEventListener(MouseEvent.MOUSE_MOVE, spriteMouseMove);
		}
 
		// 鼠标离开事件
		private function spriteMouseUp(event:MouseEvent):void
		{
			this.mySprite.removeEventListener(MouseEvent.MOUSE_MOVE, spriteMouseMove);
		}
 
		// 移动事件
		private function  spriteMouseMove(event:MouseEvent):void
		{
			this.mySprite.graphics.lineTo(mouseX, mouseY);
		}
	}
}

源文件下载

Tags : , ,

AS3学习之路(3) 使用组件(0 位领导批示)

打算写一个AS3+PHP+MySQL的留言本.(当初学习PHP第一个练习也是留言本-_,-+), 完成部分..使用了Flash CS3 的内置组件: TextInput, TextArea, Label 及 Button

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.display.StageScaleMode;
	import flash.display.StageAlign;
	import fl.controls.Label;
	import fl.controls.TextInput;
	import fl.controls.TextArea;
	import fl.controls.Button;
 
	public class ClassMain extends Sprite
	{
		private var userName:TextInput;
		private var userNameLabel:Label;
		private var message:TextArea;
		private var messageLabel:Label;
		private var button:Button;
 
		// 构造函数
		public function ClassMain()
		{
			stage.scaleMode = "noScale";
			stage.align = StageAlign.TOP_LEFT;
 
			this.initMc();
		}
 
		// 一点准备工作
		private function initMc():void
		{
			this.userName = new TextInput();
			addInput(this.userName, "userName", 50, 10, 200, 18);
 
			this.userNameLabel = new Label();
			addLabel(this.userNameLabel, "呢称:", 10, 10, 40, 18);
 
			this.message = new TextArea();
			addTextArea(this.message, "message", 50, 40, 400, 100);
 
			this.messageLabel = new Label();
			addLabel(this.messageLabel, "留言:", 10, 40, 40, 18);
 
			this.button = new Button();
			addButton(this.button, "提交", 350, 150);
		}
 
		// 创建Label
		private function addLabel(label:Label, text:String, x:uint, y:uint, width:uint, height:uint):void
		{
			label.text = text;
			label.move(x, y);
			label.setSize(width, height);
			addChild(label);
		}
 
		// 创建文本框
		private function addInput(input:TextInput, name:String, x:uint, y:uint, width:uint, height:uint):void
		{
			input.name = name;
			input.move(x, y);
			input.setSize(width, height);
			addChild(input);
		}
 
		// 创建文本域
		private function addTextArea(textArea:TextArea, name:String, x:uint, y:uint, width:uint, height:uint):void
		{
			textArea.name = name;
			textArea.move(x, y);
			textArea.setSize(width, height);
			textArea.condenseWhite = true; 
			addChild(textArea);
		}
 
		// 创建按钮
		private function addButton(button:Button, value:String, x:uint, y:uint):void
		{
			button.label= value;
			button.move(x, y);
			addChild(button);
		}
	}
 
}

未完成之前..源码还是不放出了..

Tags : , ,

AS3学习之路(2) 读取XML(1 位领导批示)

AS3对XML的操作实在是太方便了(E4X ECMAScript for XML 没错.就是ECMAScript 如果JS比较好的同学对这个也很熟悉吧)..

AS2时读取XML需要用到 firstchild 等奇怪的东东.. 看来没学过AS2也是很有好处的..活活..

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package
{
	import flash.display.*;
	import flash.text.*;
	import flash.xml.*;
	import flash.net.*;
	import flash.events.Event;
 
	public class ClassSubFeed extends Sprite
	{
		var temp:TextField;	
		var myXmlUrl:URLRequest;
		var myLoader:URLLoader;
		var xmlUrl:String;
		var xmlContent:XML;
 
		public function ClassSubFeed()
		{
			temp = new TextField();
			temp.x = 10;
			temp.y = 10;
			temp.width = 530;
			temp.height = 350;
			temp.border = true;
			temp.borderColor = 0x669900;
			temp.multiline = true;
			temp.htmlText = 'loading.....';
			addChild(temp);
 
			// xml地址
			xmlUrl = "http://www.zdyi.com/feed";
			this.loadXml(xmlUrl);
		}
 
		private function loadXml(xmlUrl:String):void
		{
			myXmlUrl = new URLRequest(xmlUrl);
			myLoader = new URLLoader(myXmlUrl);
			myLoader.addEventListener(Event.COMPLETE, onloaded);
		}
 
		private function onloaded(event):void
		{
			xmlContent = XML(myLoader.data);
			temp.htmlText = '已经读取feed,正在准备.....';
			this.parseData(xmlContent);
		}
 
		private function parseData(xmlContent:XML):void
		{
			var rrsTitle:String = xmlContent.channel.title;
			var rrsLink:String = xmlContent.channel.link;
			temp.htmlText = "<h3><a href='" + rrsLink + "' target='_blank'>" + rrsTitle + "</a></h3><br /><br />";
 
			for each(var item:XML in xmlContent..item)
			{
				var itemTitle:String = item.title.toString();
				var itemLink:String = item.link.toString();
				temp.htmlText += "<div><h4><a href='" + itemLink + "' target='_blank'>" + itemTitle + "</a></h4></div><br /><br />";
			}
		}
	}
}

源文件下载

Tags : , ,

随机显示的10篇日志

评论最多的10篇日志

浏览最多的10篇日志