sampledepth.as
来自「《Flash AS3殿堂之路》光盘源码 学习ActionScript 3.0」· AS 代码 · 共 36 行
AS
36 行
package org.kingda.book.display
{
import flash.display.Sprite;
public class SampleDepth extends Sprite
{
public function SampleDepth() {
var foo:Sprite = new Sprite();
//这儿使用同包的StarShape类和RectSprite类,不需要import
var star:StarShape = new StarShape();
var rect:RectSprite = new RectSprite("Rect", 0xFF9900);
star.x =100;
star.y = 100;
rect.x = 50;
rect.y = 50;
foo.x = 50;
foo.y = 50;
//两个都加入foo中。读者可以将下面两行顺序互换,查看效果
foo.addChild(star);
foo.addChild(rect);
star.name = "kingda";
rect.name = "kingda";
//使用getChildIndex方法得到这两个子对象在列表中的索引值
trace (foo.getChildIndex(star));//输出:0
trace (foo.getChildIndex(rect));//输出:1
trace (foo.getChildByName("kingda"));
//使用foo绘制灰色圆形,会发现这个矢量图成为背景图
foo.graphics.beginFill(0xCCCCCC);
foo.graphics.drawCircle(100,100,100);
foo.graphics.endFill();
//将foo加入显示列表
addChild(foo);
trace (foo.numChildren);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?