Attaching movieclip class without library symbol

不用库符号附加影片简辑类的方法,看这里
也就是说不用在库中创建影片剪辑就可以使用类.

P.S.AS2类的大小限制
Peter Joel 的方法:
class Rectangle extends MovieClip{
static var symbolName:String = "__Packages.Rectangle";
static var symbolOwner:Function = Rectangle;

public var width:Number = 100;
public var height:Number = 100;
public var color:Number = 0;

function Rectangle (){
draw();
}

function draw():Void{
beginFill(color);
moveTo(0,0);
lineTo(width, 0);
lineTo(width, height);
lineTo(0, height);
lineTo(0, 0);
endFill();
}

// associate the symbol to the class when the class is defined
static var symbolLinked = Object.registerClass(symbolName, symbolOwner);
}

//用法:
import Rectangle;
var initObj:Object = {width:150, height:80, color:0xFF0000};
attachMovie(Rectangle.symbolName, "rect_mc", 1, initObj);

Dave Yang 的补充:
class Actor extends MovieClip {
static var id = (id="__Packages.Actor")+(Object.registerClass(id,Actor)?"":"");

public function Actor() {
trace("Action!");
}
}

//用法:
import Actor;
attachMovie(Actor.id, "_mc", 1);

Bokel 的方法:
class Triangle extends MovieClip {
//
static function createInstance ( base_mc, name, depth){
var saveProto = MovieClip.prototype;
MovieClip.prototype = Triangle.prototype;
var mc = base_mc.createEmptyMovieClip( name, depth)
MovieClip.prototype = saveProto;
Function(Triangle).apply( mc)
return mc;
}
//
public var width:Number = 100;
public var height:Number = 100;
public var color:Number = 0;
//
//
function Triangle() {
draw();
}
//
function draw():Void {
beginFill( color);
moveTo(0, 0);
lineTo(width, 0);
lineTo(width/2, height);
lineTo(0, 0);
endFill();
}
}

//用法:
Triangle.createInstance(this, "tri_mc", 1);

ActionScript Dictionary CHM Update

update: Add fontSize Control Button

English (1.8M) | 简体中文 (1M)

注:添加了字体大小控制按钮.
LeXRus制作的是完整的帮助文档,包含了字典.
如果你只需要一个纯AS字典,就可以下载我这个版本.
补充:希望LeXRus和我的劳动能够给所有Flash开发者带来方便.
初学者有问题记得先翻翻帮助.它就是你最好的老师.
pic

ActionScript Dictionary CHM Version

新年礼物:ActionScript字典CHM完整版

>download<

pic

注:这是100%的AS字典,不是帮助文档.
包含了Flash MX 2004中所有AS,另外还有组件与Flash Comm客户&服务端AS.

P.S.英文不灵的朋友也不用担心,这里为你们准备了中文版.

点击下载

最后祝各位玩得开心!
pic

pic