月度存档: 7 月 2013

as3中设置TextField的字的间隔

var tf:TextFormat =new TextFormat();

tf.letterSpacing = 2;//字符间距

_bgmap.t_impression.top1.txt.defaultTextFormat = tf;

导航条自动换行算法

[code]
var leads:Array = new Array();
for (var i:int = 0; i < data.categories.length; i++) { //drawpoints(data.categories[i]); var _lv:LeadView = new LeadView(i, data.categories[i].name); addChild(_lv); leads.push(_lv); } leads[0].x = ystart+5; leads[0].y = sh - yend + 20; var j:int; for (i = 1; i < data.categories.length; i++) { leads[i].x = leads[i - 1].x + leads[i - 1].w + 5; if (leads[i].x+leads[i].w <= (sw - JsonData.endx)) { leads[i].y = sh - yend+20; } else { j = i; leads[j].x = ystart + 5; leads[i].y = sh - yend + 40; j++; continue; yend = 60; leads[0].y = sh - yend + 20; leads[i].y = sh - yend + 40; leads[j].x = leads[j - 1].x + leads[j - 1].w + 5; } } [/code]

Mysql基本操作

MySQL基本操作经常忘记,不如记下来留用
登陆数据库
D:\phpStudy\MySQL\bin>MySQL -uroot -proot查看数据库MySQL> show da.. 
D:\phpStudy\MySQL\bin>MySQL -uroot -proot

查看数据库
MySQL> show databases;
选择数据库
MySQL> use bugfree;
设置字符集
MySQL> set names 'gbk';
查询数据库中的表
MySQL> show tables;
MySQL基本操作创建表
MySQL> create table test(
-> tid int(10) not null,
-> tname varchar(100) not null,
-> tdate datetime not null default '0000-00-00',
-> primary key (tid));
查看表结构
MySQL> desc test;
添加列
MySQL> alter table test add(tage int(3));
修改原表结构
MySQL> alter table test modify tage int(5) not null;
修改列的默认值
MySQL> alter table test alter tage set default '0';
去掉列的默认值
MySQL> alter table test alter tage drop default;
删除列
MySQL> alter table test drop column tage;
插入数据
MySQL> insert into test(tid,tname,tdate) value(1,'yangjuqi','2008-03-21');
查询数据
MySQL> select * from test;
模糊查询
MySQL> select * from test where tname like '%杨%';
修改数据
MySQL> update test set tname='张三' where tid='2';
MySQL基本操作删除数据
MySQL> delete from test where tid='2';
删除表
MySQL> drop table test;
重命名表
MySQL> alter table test rename testbak;
分页查询(limit 起始行,取多少行)
MySQL> select * from testbak limit 2,1;
刷新数据库
MySQL> flush privileges;
显示数据库版本
MySQL> select version();
显示当前时间
MySQL> select current_date;
修改用户密码
D:\phpStudy\MySQL\bin>MySQLadmin -uroot -proot password yangjuqi
将查询出的数据写入文件
MySQL> select * from testbak into outfile "d:/test.txt" fields terminated by ",";
查看数据库状态
MySQL> status;
MySQL基本操作查看所有编码
MySQL> show variables like 'character_set_%';
导入sql文件命令
MySQL>source d:/MySQL.sql;

linux拷贝文件命令

CP命令
格式: CP [选项]  源文件或目录   目的文件或目录
选项说明:-b 同名,备分原来的文件
        -f 强制覆盖同名文件

-r 按递归方式保留原目录结构复制文件!!!!!!

linux下载打包解压命令

wget http://wordpress.org/latest.tar.gz
Then unzip the package using:
tar -xzvf latest.tar.gz
打包文件夹:
tar cvzf xxx.tar.gz xxx/

createjs框架学习笔记1

开发环境及工具参考上一篇文章:用flashdevelop创建createjs应用
下面这段实现让红色球在浏览器上来回跑,及创建点击事件
[code]
var a;
Main.prototype.createCircle = function () // 相当于as3里Main类下面的public createCircle方法
{
a = new createjs.Shape();
a.graphics.beginFill(“#FF0000”).drawCircle(0, 0, 50);
a.graphics.endFill();
a.x = 50;
a.y = 200;

a.addEventListener(“click”,clickHandle);
function clickHandle(event)
{
console.log(“test”);
}

createjs.Tween.get(a,{loop:true}).to({x:450},3000).to({x:50},3000);

this.mainStage.addChild(a);
};
[/code]

用flashdevelop创建createjs应用

最近cdc大会上各大牛分享了如何把flash技能延续到html5中,虽然我不喜欢js各种乱七八糟的写法,但是工作如果需要还是应该研究下,毕竟还没到财务自由的程度.下面入正题,我习惯用flashdevelop当编辑器,所以自然想让其成为js开发工具了,幸运的是flashdevelop新建项目的时候,已经加入了createjs app的模板,可以一键生成很多初始化的操作,cool,除此以外,js自定义函数也可以代码提示,基本符合我要求了,开工.
主要逻辑都在src/js/Main.js里面了,直接贴代码:
[code]
/** @define {string} */
var BUILD = “debug”;

(function(){

/**
* Main class of the app.
*/
function Main(){}

/**
* Entry point of the app.
*/
Main.main = function() // 相当于as3里Main类下面的static main方法
{
var main = new Main();
if (!window.HTMLCanvasElement)
{
alert(“Your browser does not support HTML5 Canvas.”);
return;
}
else main.initialize();
// entry point
main.createCircle();
}

var c = 3;
var d = 5;
var a;
Main.prototype.createCircle = function () // 相当于as3里Main类下面的public createCircle方法
{
a = new createjs.Shape();
a.graphics.beginFill(“#FF0000”);
a.graphics.drawCircle(0, 0, 30);
a.graphics.endFill();
a.x = 250;
a.y = 250;
this.mainStage.addChild(a);
};

/**
* Initializes the basics of the app.
/
Main.prototype.initialize = function()
{
/**
* mainCanvas
*/
this.mainCanvas = document.getElementById(“mainCanvas”);
/**
* mainStage
*/
this.mainStage = new createjs.Stage(this.mainCanvas);
this.mainStage.snapToPixelsEnabled = true;
/

* createjs
*/
createjs.Ticker.addListener(this);
createjs.Ticker.useRAF = true;
createjs.Ticker.setFPS(60);
}

/**
* Updates the stage on Ticker tick.
* @param event The recieved tick event.
*/
Main.prototype.tick = function(event)
{
a.x += c;
a.y += d;
if (0 > a.x – 30 || a.x + 30 > this.mainCanvas.width) c *= -1;
if (0 > a.y – 30 || a.y + 30 > this.mainCanvas.height) d *= -1;
this.mainStage.update();
}

/**
* Expose class.
*/
window.Main = Main;

})();

[/code]

然后直接run,就看到个红色的圆在浏览器里上蹦下跳了,哈哈
这些代码里面,只有
[code]main.createCircle();[/code]及
[code]var c = 3;
var d = 5;
var a;
Main.prototype.createCircle = function () // 相当于as3里Main类下面的public createCircle方法
{
a = new createjs.Shape();
a.graphics.beginFill(“#FF0000”);
a.graphics.drawCircle(0, 0, 30);
a.graphics.endFill();
a.x = 250;
a.y = 250;
this.mainStage.addChild(a);
};
[/code]

[code]
a.x += c;
a.y += d;
if (0 > a.x – 30 || a.x + 30 > this.mainCanvas.width) c *= -1;
if (0 > a.y – 30 || a.y + 30 > this.mainCanvas.height) d *= -1;
[/code]
是我加上去的,其他都是模板代码,无敌high了
用flashdevelop创建createjs应用

最好用的web开发编辑器

试过了webstrom和aptana,最后发现最好用的web开发编辑器竟然是flashdevelop!!!!
通过createjs开发框架可以把以前用flash做的项目高效转换成html5项目,再加上flashcc的无敌html5动画输出功能,fd简直是web开发中的神器!!!!!!!!!!!!

CDC大会ppt分享地址

CDC大会ppt分享地址

as3判断加载文件格式文件类型

[code]
var url:String =”http://bbs.blueidea.com/images/common/back.gif”;
var tempArr:Array = url.split(“.”)
trace(tempArr[tempArr.length-1]);
[/code]
contentType可以显示加载的类型,对应类型:
swf-“application/x-shockwave-flash”
jpg-“image/jpeg”
gif-“image/gif”
png-“image/png”
[code]
var loader:Loader=new Loader();
loader.load(new URLRequest(“http://bbs.blueidea.com/images/default/logo.gif”));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, LoadEnd);
function LoadEnd(evt:Event):void {
trace(evt.target.contentType);
}
[/code]