-
2008-04-20一个用as3模拟as2的MovieClip类 - [flash 游戏 3d]
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://dayuhome.blogbus.com/logs/19388127.html
这个类比较简单,不习惯as3可视化类的同学可以试试
使用方法很简单,所有可视化类都可以继承自该类。
比如文档类继承这个类,可以用
this.attachMovie(可视化类名,实例名);来创建影片剪辑
然后就可以用 this.实例名引用那个剪辑了
this.removeMovie(可视化类名,实例名);来删除影片剪辑
是不是和as2的很一样呢。
package{
import flash.display.DisplayObject;
import flash.display.Sprite;
/**
* @author dayu
* @deprecated 本类是为了纪念as2而存在,对于怀念as2的同学,
* 使用本类。将让你感到一种亲切感
*
*/
dynamic public class EmptyMovie extends Sprite {
var pen:Pen;
public function EmptyMovie() {
super();
pen=new Pen();
}
public function attachMovie(cl:Class,nam:String) {
this[nam]=new cl();
this.addChild(this[nam]);
return this[nam];
}
public function removeMovie(nam:String){
this.removeChild(this[nam]);
delete this[nam];
}
//设定笔刷相关
public function setpen(thickness,color,alpha){
this.pen.thickness=thickness;
this.pen.color=color;
this.pen.alpha=alpha;
this.graphics.lineStyle(pen.thickness,pen.color,pen.alpha);
}
public function resetpen(){
this.graphics.lineStyle(pen.thickness,pen.color,pen.alpha);
}
public function setbrush(color){
this.graphics.beginFill(color,1);
}
//设定绘图相关
public function clear(){
this.graphics.clear();
}
public function beginFill(color:uint){
this.graphics.beginFill(color);
}
public function endFill(){
this.graphics.endFill();
}
public function drawCircle(x, y, radius){
this.graphics.drawCircle(x, y, radius);
}
public function drawEllipse(x, y, width, height){
this.graphics.drawEllipse(x, y, width, height);
}
public function drawRect(x, y, width, height){
this.graphics.drawRect(x, y, width, height);
}
public function drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight){
this.graphics.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight);
}
public function lineTo(x, y){
this.graphics.lineTo(x, y);
}
public function moveTo(x, y){
this.graphics.moveTo(x, y);
}
}
}
class Pen extends Object{
public var thickness:int;
public var color:uint;
public var alpha:Number;
function Pen(thick=2,col=0xffffff,a=1){
thickness=thick;
color=col;
alpha=a;
}
public function clone(pen:Pen):Pen{
return new Pen(thickness,color,alpha);
}
}
随机文章:
游戏中的ai-决策 2008-07-23as3触发器编辑器0.8版本完成纪念 2008-07-01flash player的漏洞,赶紧升级player 2008-06-27也推荐 object-oriented as3 2007-12-04贴2张本人的3d引擎渲染的效果图 2007-08-16
收藏到:Del.icio.us







