fractal_branch_class.as
来自「这是《Flash MX编程与创意实现》的源代码」· AS 代码 · 共 96 行
AS
96 行
/*
FractalBranch Class v1.1
Oct. 29, 2002
(c) 2002 Robert Penner
The FractalBranch is a MovieClip subclass that encapsulates
the behavior of a branch of the fractal tree.
Dependencies: MotionCam class
Discussed in Chapter 13 of
Robert Penner's Programming Macromedia Flash MX
Used in the Fractal Dancer animation.
http://www.robertpenner.com/profmx
http://www.amazon.com/exec/obidos/ASIN/0072223561/robertpennerc-20
*/
#initclip 2
_global.FractalBranch = function () {
this.init();
};
Object.registerClass ("FractalBranchSymbol", FractalBranch);
FractalBranch.prototype.__proto__ = MovieClip.prototype;
var FBP = FractalBranch.prototype;
FBP.init = function () {
this.numBranches = 0;
if (this.myLevel == undefined) {
this.myLevel = 0;
this.fRoot = this._parent;
} else {
this.doColor();
if (this.myBranch == 1)
this.fRoot.xCam.addListener (this);
else if (this.myBranch == 2)
this.fRoot.yCam.addListener (this);
}
};
// event handler - event comes from a MotionCam instance
FBP.onMotionChanged = function (source, position) {
if (position != undefined)
this._rotation = position + 175;
};
FBP.doColor = function () {
if (this.myBranch == 1)
var tint = {r:255, g:255, b:255};
else
var tint = {r:0, g:0, b:255};
(new Color (this)).setTint (tint.r,
tint.g,
tint.b,
30);
};
FBP.newBranch = function (bNum) {
if (this.myLevel >= this.fRoot.maxLevels) return;
var p = this.fRoot.posers[bNum];
var initObj = {
_x: p._x,
_y: p._y,
_xscale: p._xscale,
_yscale: p._yscale,
_rotation: p._rotation,
myLevel: this.myLevel + 1,
myBranch: bNum,
fRoot: this.fRoot
}
this.attachMovie ("FractalBranchSymbol",
"b" + bNum,
bNum,
initObj);
this.numBranches++;
};
FBP.nextBranch = function () {
if (this.numBranches < this.fRoot.maxBranches
&& this.myLevel < this.fRoot.maxLevels) {
this.newBranch (this.numBranches + 1);
} else {
this._parent.nextBranch();
}
};
delete FBP;
#endinitclip
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?