📄 sampledepth.as
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -