博客公告(点击显示/隐藏)| 今日心情:神学
2010-07-30 21:09:43
小S吧今天你来了吗?更新速度:每周2-3篇以上!在俺博客看到有用的东西,学习了之后,记得回访带点人气哦 ^_^ 嘿嘿!
欢迎跟俺交换友情链接啊。。留言,直接QQ等联系我都行啊
转载本博客文章请注明:来源小S吧——sunbright博客,链接地址:http://www.xiaos8.com
2008
1-16
欢迎多多提程序方面的意见,先公布源代码,欢迎高手指导
查看最新版对对碰,请点下面这个链接
http://www.kongregate.com/games/sunbright/bumping-friuts首先是fla主文件
这个类中讲了一个设计模式的定义,该设计模式定义,是我自己总结的一些编程经验,归纳写下来的,希望在设计模式上有一定造诣的高手,多给指点!
查看最新版对对碰,请点下面这个链接
http://www.kongregate.com/games/sunbright/bumping-friuts首先是fla主文件
import index.item.lookAgain.Vessel;var scene:Vessel = new Vessel;
scene.x = scene.y = 30;
addChild(scene);var txt:TextField = new TextField;
txt.htmlText = "九宫对对碰 V1版\n作者:sunbright\n玩法:将相邻的两个方块相互交换,如果促成一条线都是同样形状,则消除成功(45°斜线亦可)\n\n胡乱瞎搞的练手之作,因为本身美工不好,所以在美工方面没下功夫,请见谅。\n\n源代码已在<a href='http://www.xiaos8.com'target='_blank'><font color='#0000ff'><u>我的博客</u></font></a>公开\n\n谢谢观看,欢迎来我博客交流技术问题\n\n\n欢迎光临小S吧\n\n<a href='http://www.xiaos8.com' target='_blank'><font color='#0000ff'><u>sunbright博客\n点击进入</u></font></a>\n\n<a href='http://www.xiaos8.com/article.asp?id=44' target='_target'><font color='#0000ff'><u>直接进入源代码帖子浏览</u></font></a>";
txt.setTextFormat(new TextFormat("Arial"));
txt.multiline = txt.wordWrap = true;
txt.selectable = false;
txt.width = 120;
txt.height = 400;
txt.x = 420;
txt.y = 10;addChild(txt);
然后是index.item.lookAgain.Vessel.as类文件:scene.x = scene.y = 30;
addChild(scene);var txt:TextField = new TextField;
txt.htmlText = "九宫对对碰 V1版\n作者:sunbright\n玩法:将相邻的两个方块相互交换,如果促成一条线都是同样形状,则消除成功(45°斜线亦可)\n\n胡乱瞎搞的练手之作,因为本身美工不好,所以在美工方面没下功夫,请见谅。\n\n源代码已在<a href='http://www.xiaos8.com'target='_blank'><font color='#0000ff'><u>我的博客</u></font></a>公开\n\n谢谢观看,欢迎来我博客交流技术问题\n\n\n欢迎光临小S吧\n\n<a href='http://www.xiaos8.com' target='_blank'><font color='#0000ff'><u>sunbright博客\n点击进入</u></font></a>\n\n<a href='http://www.xiaos8.com/article.asp?id=44' target='_target'><font color='#0000ff'><u>直接进入源代码帖子浏览</u></font></a>";
txt.setTextFormat(new TextFormat("Arial"));
txt.multiline = txt.wordWrap = true;
txt.selectable = false;
txt.width = 120;
txt.height = 400;
txt.x = 420;
txt.y = 10;addChild(txt);
package index.item.lookAgain{
import flash.display.Sprite;
import flash.events.TextEvent;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.utils.setTimeout;
import index.base.program.TwoArray;
import index.item.lookAgain.Thing;
import index.item.lookAgain.Painting;
public class Vessel extends Sprite{
private const listAr:Array = new Array("circle","square","rectangle","triangle","ellipse","hexagon","trapezoid","parallelogram","rhombus","star");
private const z:TwoArray = new TwoArray(10,10);
private var thingAr:Array = new Array;
private var tmpAr:Array;
private const _scoreText:TextField = new TextField;
private var _score:uint;
private const _timesText:TextField = new TextField;
private var _times:uint;
public function Vessel(){
mouseEnabled = false;
//设置默认分数,重新排列次数
score = 0;
times = 0;
//设置分数,重新排列次数的文本框
_scoreText.mouseEnabled =
_scoreText.selectable =
_timesText.selectable = false;
_scoreText.autoSize = "left"
_timesText.autoSize = "right";
_scoreText.y =
_timesText.y = 380;
_timesText.x = 200;
addChild(_scoreText);
addChild(_timesText); _timesText.addEventListener(TextEvent.LINK,reload);
z.traversal(function(ar:int,ix:int,iy:int):void
{
createThing(ix,iy);
}); addEventListener(MouseEvent.MOUSE_OVER,funOver);
addEventListener(MouseEvent.MOUSE_OUT,funOut);
addEventListener(MouseEvent.CLICK,funClick);
if(expSuccess()){
setTimeout(clearThing,200);
}
}
//重新排列
private function reload(e:TextEvent):void{
if(_times > 0){
times --;
z.traversal(function(ar:int,ix:int,iy:int):void
{
removeChild(getChildByName(ix + "_" + iy));
createThing(ix,iy);
});
if(expSuccess()){
setTimeout(clearThing,200);
}
}
}
//鼠标滑过事件
private function funOver(e:MouseEvent):void{
if(e.target is Thing) e.target.toBig();
} //鼠标离开事件
private function funOut(e:MouseEvent):void{
if(e.target is Thing) e.target.toSmall();
} //鼠标单击事件
private function funClick(e:MouseEvent):void{
if(e.target is Thing){
if(e.target.isTo){
e.target.isTo = false;
thingAr.push(e.target as Thing);
if(thingAr.length == 2){
exchange(thingAr[0],thingAr[1]);
}
}
}
} //两个东西调换
private function exchange(t1:Thing,t2:Thing):void{
if(Math.abs(t1.ix - t2.ix) < 2 && Math.abs(t1.iy - t2.iy) < 2){
exchangeData(t1,t2);
if(expSuccess()){
setTimeout(clearThing,200);
}else{
setTimeout(exchangeData,200,t2,t1);
}
}
t1.isTo = true;
t2.isTo = true;
thingAr = new Array;
}
//数据交换
private function exchangeData(t1:Thing,t2:Thing):void{
//交换ix,iy值
var tmpx:uint = t1.ix;
var tmpy:uint = t1.iy;
t1.ix = t2.ix;
t1.iy = t2.iy;
t2.ix = tmpx;
t2.iy = tmpy;
//交换数字标识
var tmpNum:int = z[t1.ix][t1.iy];
z[t1.ix][t1.iy] = z[t2.ix][t2.iy];
z[t2.ix][t2.iy] = tmpNum;
//交换实例名
var tmpStr:String = t1.name;
t1.name = t2.name;
t2.name = tmpStr;
}
//检测是否有成功项
private function expSuccess():Boolean{
tmpAr = new Array;
z.traversal(function(ar:int,ix:int,iy:int):void
{
expPoint(ix,iy);
});
return Boolean(tmpAr.length);
}
//检测相对某点的成功项
private function expPoint(ix:int,iy:int):void{
expLine(ix,iy,ix+1,iy,ix+2,iy);
expLine(ix,iy,ix+1,iy,ix-1,iy);
expLine(ix,iy,ix-1,iy,ix-2,iy);
expLine(ix,iy,ix,iy+1,ix,iy+2);
expLine(ix,iy,ix,iy+1,ix,iy-1);
expLine(ix,iy,ix,iy-1,ix,iy-2);
expLine(ix,iy,ix+1,iy+1,ix+2,iy+2);
expLine(ix,iy,ix+1,iy+1,ix-1,iy-1);
expLine(ix,iy,ix-1,iy-1,ix-2,iy-2);
expLine(ix,iy,ix+1,iy-1,ix+2,iy-2);
expLine(ix,iy,ix+1,iy-1,ix-1,iy+1);
expLine(ix,iy,ix-1,iy+1,ix-2,iy+2);
}
//是否3点一样
private function expLine(ix1:int,iy1:int,ix2:int,iy2:int,ix3:int,iy3:int):void{
if(ix1 < 0 || ix2 < 0 || ix3 < 0 || iy1 < 0 || iy2 < 0 || iy3 < 0 || ix1 > 9 || ix2 > 9 || ix3 > 9 || iy1 > 9 || iy2 > 9 || iy3 > 9 || z[ix1][iy1] == undefined || z[ix2][iy2] == undefined || z[ix3][iy3] == undefined){
return;
}
if(z[ix1][iy1] == z[ix2][iy2] && z[ix3][iy3] == z[ix2][iy2]){
tmpAr.push(getChildByName(ix1 + "_" + iy1));
tmpAr.push(getChildByName(ix2 + "_" + iy2));
tmpAr.push(getChildByName(ix3 + "_" + iy3));
}
}
//消除方块
private function clearThing():void{
//去掉同样的项目
tmpAr = tmpAr.sort().filter(function(item:Thing, index:int, array:Array):Boolean
{
while(index > 0){
if(item == array[-- index]){
return false;
}
}
return true;
});
//消除方块
for(var i:int = 0; i < tmpAr.length; i ++){
if(tmpAr[i] != null){
if(contains(tmpAr[i])){
removeChild(tmpAr[i]);
score ++;
setTimeout(createThing,200,tmpAr[i].ix,tmpAr[i].iy);
}
}
}
//再次检查是否有成功项
if(expSuccess()){
setTimeout(clearThing,200);
}
}
//生成一个方块
private function createThing(ix:int,iy:int):void{
z[ix][iy] = Math.floor(Math.random() * 10);
var tmpSpr:Thing = Painting.draw(listAr[z[ix][iy]]);
tmpSpr.name = ix + "_" + iy;
tmpSpr.ix = ix;
tmpSpr.iy = iy;
addChild(tmpSpr);
}
//设置分数
private function set score(num:int):void{
_score = num;
_scoreText.text = "一共得 " + _score * 100 + " 分";
//判断是否过了100次方块消除,如果是增加一次重新排列使用机会
if(_score / 100 == Math.floor(_score / 100)){
times ++;
}
}
//获取真实分数
private function get score():int{
return _score;
}
//设置重新排列次数
private function set times(num:int):void{
_times = num;
_timesText.htmlText = "您还有 " + num + " 次机会使用 <a href='event:'><u>重新排列</u></a>";
}
//获取重新排列次数
private function get times():int{
return _times;
}
}
}
再是index.item.lookAgain.Thing.as文件import flash.display.Sprite;
import flash.events.TextEvent;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.utils.setTimeout;
import index.base.program.TwoArray;
import index.item.lookAgain.Thing;
import index.item.lookAgain.Painting;
public class Vessel extends Sprite{
private const listAr:Array = new Array("circle","square","rectangle","triangle","ellipse","hexagon","trapezoid","parallelogram","rhombus","star");
private const z:TwoArray = new TwoArray(10,10);
private var thingAr:Array = new Array;
private var tmpAr:Array;
private const _scoreText:TextField = new TextField;
private var _score:uint;
private const _timesText:TextField = new TextField;
private var _times:uint;
public function Vessel(){
mouseEnabled = false;
//设置默认分数,重新排列次数
score = 0;
times = 0;
//设置分数,重新排列次数的文本框
_scoreText.mouseEnabled =
_scoreText.selectable =
_timesText.selectable = false;
_scoreText.autoSize = "left"
_timesText.autoSize = "right";
_scoreText.y =
_timesText.y = 380;
_timesText.x = 200;
addChild(_scoreText);
addChild(_timesText); _timesText.addEventListener(TextEvent.LINK,reload);
z.traversal(function(ar:int,ix:int,iy:int):void
{
createThing(ix,iy);
}); addEventListener(MouseEvent.MOUSE_OVER,funOver);
addEventListener(MouseEvent.MOUSE_OUT,funOut);
addEventListener(MouseEvent.CLICK,funClick);
if(expSuccess()){
setTimeout(clearThing,200);
}
}
//重新排列
private function reload(e:TextEvent):void{
if(_times > 0){
times --;
z.traversal(function(ar:int,ix:int,iy:int):void
{
removeChild(getChildByName(ix + "_" + iy));
createThing(ix,iy);
});
if(expSuccess()){
setTimeout(clearThing,200);
}
}
}
//鼠标滑过事件
private function funOver(e:MouseEvent):void{
if(e.target is Thing) e.target.toBig();
} //鼠标离开事件
private function funOut(e:MouseEvent):void{
if(e.target is Thing) e.target.toSmall();
} //鼠标单击事件
private function funClick(e:MouseEvent):void{
if(e.target is Thing){
if(e.target.isTo){
e.target.isTo = false;
thingAr.push(e.target as Thing);
if(thingAr.length == 2){
exchange(thingAr[0],thingAr[1]);
}
}
}
} //两个东西调换
private function exchange(t1:Thing,t2:Thing):void{
if(Math.abs(t1.ix - t2.ix) < 2 && Math.abs(t1.iy - t2.iy) < 2){
exchangeData(t1,t2);
if(expSuccess()){
setTimeout(clearThing,200);
}else{
setTimeout(exchangeData,200,t2,t1);
}
}
t1.isTo = true;
t2.isTo = true;
thingAr = new Array;
}
//数据交换
private function exchangeData(t1:Thing,t2:Thing):void{
//交换ix,iy值
var tmpx:uint = t1.ix;
var tmpy:uint = t1.iy;
t1.ix = t2.ix;
t1.iy = t2.iy;
t2.ix = tmpx;
t2.iy = tmpy;
//交换数字标识
var tmpNum:int = z[t1.ix][t1.iy];
z[t1.ix][t1.iy] = z[t2.ix][t2.iy];
z[t2.ix][t2.iy] = tmpNum;
//交换实例名
var tmpStr:String = t1.name;
t1.name = t2.name;
t2.name = tmpStr;
}
//检测是否有成功项
private function expSuccess():Boolean{
tmpAr = new Array;
z.traversal(function(ar:int,ix:int,iy:int):void
{
expPoint(ix,iy);
});
return Boolean(tmpAr.length);
}
//检测相对某点的成功项
private function expPoint(ix:int,iy:int):void{
expLine(ix,iy,ix+1,iy,ix+2,iy);
expLine(ix,iy,ix+1,iy,ix-1,iy);
expLine(ix,iy,ix-1,iy,ix-2,iy);
expLine(ix,iy,ix,iy+1,ix,iy+2);
expLine(ix,iy,ix,iy+1,ix,iy-1);
expLine(ix,iy,ix,iy-1,ix,iy-2);
expLine(ix,iy,ix+1,iy+1,ix+2,iy+2);
expLine(ix,iy,ix+1,iy+1,ix-1,iy-1);
expLine(ix,iy,ix-1,iy-1,ix-2,iy-2);
expLine(ix,iy,ix+1,iy-1,ix+2,iy-2);
expLine(ix,iy,ix+1,iy-1,ix-1,iy+1);
expLine(ix,iy,ix-1,iy+1,ix-2,iy+2);
}
//是否3点一样
private function expLine(ix1:int,iy1:int,ix2:int,iy2:int,ix3:int,iy3:int):void{
if(ix1 < 0 || ix2 < 0 || ix3 < 0 || iy1 < 0 || iy2 < 0 || iy3 < 0 || ix1 > 9 || ix2 > 9 || ix3 > 9 || iy1 > 9 || iy2 > 9 || iy3 > 9 || z[ix1][iy1] == undefined || z[ix2][iy2] == undefined || z[ix3][iy3] == undefined){
return;
}
if(z[ix1][iy1] == z[ix2][iy2] && z[ix3][iy3] == z[ix2][iy2]){
tmpAr.push(getChildByName(ix1 + "_" + iy1));
tmpAr.push(getChildByName(ix2 + "_" + iy2));
tmpAr.push(getChildByName(ix3 + "_" + iy3));
}
}
//消除方块
private function clearThing():void{
//去掉同样的项目
tmpAr = tmpAr.sort().filter(function(item:Thing, index:int, array:Array):Boolean
{
while(index > 0){
if(item == array[-- index]){
return false;
}
}
return true;
});
//消除方块
for(var i:int = 0; i < tmpAr.length; i ++){
if(tmpAr[i] != null){
if(contains(tmpAr[i])){
removeChild(tmpAr[i]);
score ++;
setTimeout(createThing,200,tmpAr[i].ix,tmpAr[i].iy);
}
}
}
//再次检查是否有成功项
if(expSuccess()){
setTimeout(clearThing,200);
}
}
//生成一个方块
private function createThing(ix:int,iy:int):void{
z[ix][iy] = Math.floor(Math.random() * 10);
var tmpSpr:Thing = Painting.draw(listAr[z[ix][iy]]);
tmpSpr.name = ix + "_" + iy;
tmpSpr.ix = ix;
tmpSpr.iy = iy;
addChild(tmpSpr);
}
//设置分数
private function set score(num:int):void{
_score = num;
_scoreText.text = "一共得 " + _score * 100 + " 分";
//判断是否过了100次方块消除,如果是增加一次重新排列使用机会
if(_score / 100 == Math.floor(_score / 100)){
times ++;
}
}
//获取真实分数
private function get score():int{
return _score;
}
//设置重新排列次数
private function set times(num:int):void{
_times = num;
_timesText.htmlText = "您还有 " + num + " 次机会使用 <a href='event:'><u>重新排列</u></a>";
}
//获取重新排列次数
private function get times():int{
return _times;
}
}
}
package index.item.lookAgain{
import flash.display.Sprite;
public class Thing extends Sprite{
private var _isTo:Boolean = true;
private var _ix:uint;
private var _iy:uint;
private var pro:uint;
public function Thing(num:uint = 40){
pro = num;
mouseChildren = false;
}
//设置是否响应变大,变小
public function set isTo(p:Boolean):void{
_isTo = true;
if(p){
toSmall();
}else{
toBig();
}
_isTo = p;
}
//设置是否响应变大,变小
public function get isTo():Boolean{
return _isTo;
}
//设置x系数
public function set ix(num:uint):void{
x = num * pro;
_ix = num;
}
//获取x系数
public function get ix():uint{
return _ix;
}
//设置y系数
public function set iy(num:uint):void{
y = num * pro;
_iy = num;
}
//获取y系数
public function get iy():uint{
return _iy;
}
//变大
public function toBig():void{
if(_isTo){
getChildAt(0).scaleX =
getChildAt(0).scaleY = 0.8;
graphics.clear();
graphics.lineStyle(2,0);
graphics.beginFill(0xffdddd,1);
graphics.drawRect(-20,-20,40,40);
}
}
//变小
public function toSmall():void{
if(_isTo){
getChildAt(0).scaleX =
getChildAt(0).scaleY = 0.6;
graphics.clear();
graphics.lineStyle(1,0x336699);
graphics.beginFill(0xffffff,0);
graphics.drawRect(-20,-20,40,40);
}
}
//改写toString
override public function toString():String{
return name;
}
}}
接下来是index.item.lookAgain.Painting.as文件:import flash.display.Sprite;
public class Thing extends Sprite{
private var _isTo:Boolean = true;
private var _ix:uint;
private var _iy:uint;
private var pro:uint;
public function Thing(num:uint = 40){
pro = num;
mouseChildren = false;
}
//设置是否响应变大,变小
public function set isTo(p:Boolean):void{
_isTo = true;
if(p){
toSmall();
}else{
toBig();
}
_isTo = p;
}
//设置是否响应变大,变小
public function get isTo():Boolean{
return _isTo;
}
//设置x系数
public function set ix(num:uint):void{
x = num * pro;
_ix = num;
}
//获取x系数
public function get ix():uint{
return _ix;
}
//设置y系数
public function set iy(num:uint):void{
y = num * pro;
_iy = num;
}
//获取y系数
public function get iy():uint{
return _iy;
}
//变大
public function toBig():void{
if(_isTo){
getChildAt(0).scaleX =
getChildAt(0).scaleY = 0.8;
graphics.clear();
graphics.lineStyle(2,0);
graphics.beginFill(0xffdddd,1);
graphics.drawRect(-20,-20,40,40);
}
}
//变小
public function toSmall():void{
if(_isTo){
getChildAt(0).scaleX =
getChildAt(0).scaleY = 0.6;
graphics.clear();
graphics.lineStyle(1,0x336699);
graphics.beginFill(0xffffff,0);
graphics.drawRect(-20,-20,40,40);
}
}
//改写toString
override public function toString():String{
return name;
}
}}
这个类中讲了一个设计模式的定义,该设计模式定义,是我自己总结的一些编程经验,归纳写下来的,希望在设计模式上有一定造诣的高手,多给指点!
/**
* 设计模式:外卖模式
* 定义:提交类型,返回实例,并通过固定流程,最终返回真正实用的实例。
* 比如:外卖餐厅,打电话告诉前台服务员,需要一碗鱼香肉丝饭,一碗大排饭,提交类型:鱼香肉丝饭,大排饭;最后送到我家两份盖浇饭。在盖浇饭的生成过程中,除了鱼香肉丝和大排不同,其它所用的饭,饭盒,配菜等等,都是一样的。
*/
package index.item.lookAgain{
import flash.display.Shape;
import flash.filters.DropShadowFilter;
import flash.filters.BlurFilter;
import index.item.lookAgain.Thing;
public class Painting{
//创建东西的方法
public static function draw(type:String):Thing{
var reSha:Shape = Painting[type]();
reSha.scaleX = reSha.scaleY = 0.6;
reSha.filters = new Array(new DropShadowFilter(2),new BlurFilter(2,2,1));
var reThi:Thing = new Thing;
reThi.graphics.lineStyle(1,0x336699);
reThi.graphics.beginFill(0xffffff,0);
reThi.graphics.drawRect(-20,-20,40,40);
reThi.addChild(reSha);
return reThi;
}
//创建圆形
private static function circle():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x336699);
reSha.graphics.drawCircle(0,0,20);
return reSha;
}
//创建正方形
private static function square():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x00ff00);
reSha.graphics.drawRect(-20,-20,40,40);
return reSha;
}
//创建矩形
private static function rectangle():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x0000ff);
reSha.graphics.drawRect(-20,-10,40,20);
return reSha;
}
//创建三角形
private static function triangle():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x00ffff);
reSha.graphics.moveTo(0,-20);
reSha.graphics.lineTo(20,20);
reSha.graphics.lineTo(-20,20);
reSha.graphics.endFill();
return reSha;
}
//创建椭圆
private static function ellipse():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0xffff00);
reSha.graphics.drawEllipse(-20,-10,40,20);
return reSha;
}
//创建六边形
private static function hexagon():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0xff00ff);
reSha.graphics.moveTo(-20,0);
reSha.graphics.lineTo(-10,-20);
reSha.graphics.lineTo(10,-20);
reSha.graphics.lineTo(20,0);
reSha.graphics.lineTo(10,20);
reSha.graphics.lineTo(-10,20);
reSha.graphics.endFill();
return reSha;
}
//创建梯形
private static function trapezoid():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x999999);
reSha.graphics.moveTo(-10,-20);
reSha.graphics.lineTo(10,-20);
reSha.graphics.lineTo(20,20);
reSha.graphics.lineTo(-20,20);
reSha.graphics.endFill();
return reSha;
}
//创建平行四边形
private static function parallelogram():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x99ff99);
reSha.graphics.moveTo(-10,-20);
reSha.graphics.lineTo(20,-20);
reSha.graphics.lineTo(10,20);
reSha.graphics.lineTo(-20,20);
reSha.graphics.endFill();
return reSha;
}
//创建菱形
private static function rhombus():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x77ff33);
reSha.graphics.moveTo(0,-20);
reSha.graphics.lineTo(-15,0);
reSha.graphics.lineTo(0,20);
reSha.graphics.lineTo(15,0);
reSha.graphics.endFill();
return reSha;
}
//创建五角星
private static function star():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x770033);
reSha.graphics.moveTo(0,-20);
reSha.graphics.lineTo(15,20);
reSha.graphics.lineTo(-20,-5);
reSha.graphics.lineTo(20,-5);
reSha.graphics.lineTo(-15,20);
reSha.graphics.endFill();
return reSha;
}
}
}
最后一个导入使用过的二维数组类,这个类只是随便写了一下,方便大家了解上面,依然把类贴出来* 设计模式:外卖模式
* 定义:提交类型,返回实例,并通过固定流程,最终返回真正实用的实例。
* 比如:外卖餐厅,打电话告诉前台服务员,需要一碗鱼香肉丝饭,一碗大排饭,提交类型:鱼香肉丝饭,大排饭;最后送到我家两份盖浇饭。在盖浇饭的生成过程中,除了鱼香肉丝和大排不同,其它所用的饭,饭盒,配菜等等,都是一样的。
*/
package index.item.lookAgain{
import flash.display.Shape;
import flash.filters.DropShadowFilter;
import flash.filters.BlurFilter;
import index.item.lookAgain.Thing;
public class Painting{
//创建东西的方法
public static function draw(type:String):Thing{
var reSha:Shape = Painting[type]();
reSha.scaleX = reSha.scaleY = 0.6;
reSha.filters = new Array(new DropShadowFilter(2),new BlurFilter(2,2,1));
var reThi:Thing = new Thing;
reThi.graphics.lineStyle(1,0x336699);
reThi.graphics.beginFill(0xffffff,0);
reThi.graphics.drawRect(-20,-20,40,40);
reThi.addChild(reSha);
return reThi;
}
//创建圆形
private static function circle():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x336699);
reSha.graphics.drawCircle(0,0,20);
return reSha;
}
//创建正方形
private static function square():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x00ff00);
reSha.graphics.drawRect(-20,-20,40,40);
return reSha;
}
//创建矩形
private static function rectangle():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x0000ff);
reSha.graphics.drawRect(-20,-10,40,20);
return reSha;
}
//创建三角形
private static function triangle():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x00ffff);
reSha.graphics.moveTo(0,-20);
reSha.graphics.lineTo(20,20);
reSha.graphics.lineTo(-20,20);
reSha.graphics.endFill();
return reSha;
}
//创建椭圆
private static function ellipse():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0xffff00);
reSha.graphics.drawEllipse(-20,-10,40,20);
return reSha;
}
//创建六边形
private static function hexagon():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0xff00ff);
reSha.graphics.moveTo(-20,0);
reSha.graphics.lineTo(-10,-20);
reSha.graphics.lineTo(10,-20);
reSha.graphics.lineTo(20,0);
reSha.graphics.lineTo(10,20);
reSha.graphics.lineTo(-10,20);
reSha.graphics.endFill();
return reSha;
}
//创建梯形
private static function trapezoid():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x999999);
reSha.graphics.moveTo(-10,-20);
reSha.graphics.lineTo(10,-20);
reSha.graphics.lineTo(20,20);
reSha.graphics.lineTo(-20,20);
reSha.graphics.endFill();
return reSha;
}
//创建平行四边形
private static function parallelogram():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x99ff99);
reSha.graphics.moveTo(-10,-20);
reSha.graphics.lineTo(20,-20);
reSha.graphics.lineTo(10,20);
reSha.graphics.lineTo(-20,20);
reSha.graphics.endFill();
return reSha;
}
//创建菱形
private static function rhombus():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x77ff33);
reSha.graphics.moveTo(0,-20);
reSha.graphics.lineTo(-15,0);
reSha.graphics.lineTo(0,20);
reSha.graphics.lineTo(15,0);
reSha.graphics.endFill();
return reSha;
}
//创建五角星
private static function star():Shape{
var reSha:Shape = new Shape;
reSha.graphics.beginFill(0x770033);
reSha.graphics.moveTo(0,-20);
reSha.graphics.lineTo(15,20);
reSha.graphics.lineTo(-20,-5);
reSha.graphics.lineTo(20,-5);
reSha.graphics.lineTo(-15,20);
reSha.graphics.endFill();
return reSha;
}
}
}
/**
*二维数组类
*第一个参数为x,第二个参数为y
*使用的时候,可以完全按照数组使用
*/
package index.base.program{
public dynamic final class TwoArray extends Array{
private var itemX:uint;
private var itemY:uint;
public function TwoArray(_itemX:uint,_itemY:uint) {
itemX = _itemX;
itemY = _itemY;
for (var i:int=0; i<itemX; i++) {
var tmpY:Array=new Array(itemY);
push(tmpY);
}
}
//遍历所有组员
public function traversal(fun:Function):void{
forEach(function(element:*,itemX:int,arr:Array)
{
element.forEach(function(elements:*,itemY:int,arrs:Array)
{
fun(elements,itemX,itemY);
});
});
}
}
}
过几天写教程,大家可以先看看,有问题可以直接在评论中问~
*二维数组类
*第一个参数为x,第二个参数为y
*使用的时候,可以完全按照数组使用
*/
package index.base.program{
public dynamic final class TwoArray extends Array{
private var itemX:uint;
private var itemY:uint;
public function TwoArray(_itemX:uint,_itemY:uint) {
itemX = _itemX;
itemY = _itemY;
for (var i:int=0; i<itemX; i++) {
var tmpY:Array=new Array(itemY);
push(tmpY);
}
}
//遍历所有组员
public function traversal(fun:Function):void{
forEach(function(element:*,itemX:int,arr:Array)
{
element.forEach(function(elements:*,itemY:int,arrs:Array)
{
fun(elements,itemX,itemY);
});
});
}
}
}
2008
1-15
在蓝色理想的上海八周年聚会上,看到了由乐猫网络赞助的奖品——500M大众型空间,觉得还不错然后通过联系,办理,一个晚上时间,我也把俺的博客换成了乐猫网络的空间,如今速度比以前快多了~~免费为乐猫做个广告 http://www.60u.cn
2008
1-14
绿豆蛙 漂流岛V1版本,终于快结束了对于朋友们的关心,我表示感谢大家多多光临额~~去过之后多给建议额~~flash部分的程序都是我独立完成开发绿豆蛙 漂流岛 点击进入
2008
1-13
这几天老是有人在我博客刷广告。于是俺花了点时间,改造了一下验证码的输入方式,我绝对还行,不知道访问我博客的用户,感觉如何?
俺来打听一点用户体验方面的问题?
俺来打听一点用户体验方面的问题?
2008
1-13
今天去了ASer的一个聚会,再会的有云开,寂寞火山,kinglong,eidiot,苹果树下的AS程序员 等人不该公司的聚会也是安排在今天,因此在ASer聚会现场待了一下,就闪去了公司那边的聚会。遇见了许多传说中的牛人,虽然俺被火山说成是隐居的高人,但是在各位前辈的面前,我还是一个刚出道的小娃娃。想起07年5月份,还非常羡慕appleshow.cc的程序员和美工,今天竟然在一起聚餐。。哎,事事难料以前还在看火山的文章,拜读kinglong的教程,羡慕苹果树下的涂鸦板等等感觉仿佛还是很假的事情,其实我在4个月前还是不会AS3的,在6个月前我还是没有任何项目编程经历的人(我以前是网页美工,而且AS2也只是会点皮毛)在绿豆蛙这个项目上,在你我信息这家公司中,给了我很大的成长机会,再加上前辈的教程,文章等使我在短短的6个月成长到现在,当然最初的成长是应该谢谢阿洞的flash群,天总(天边),三围(39-24-39),猪爷爷(pig.hong)三个人的帮助不知道说什么好,随感啰嗦几句,就当留个恋,谢谢我生命中认识的每一位朋友今天去过聚会的朋友,欢迎和我博客交换友情链接额。我找了一下,只找到kinglong,Azure等人的博客




- 查看svn更新内容以及最新状态(实时更新)
- 查看框架API文档(09.6.15更新)
- 查看框架代码(09.4.20更新)
框架暂停开发,且没有完全竣工,目前只能使用air包和library包!