📄 sampleaccessbydepth.as
字号:
package org.kingda.book.display
{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Shape;
public class SampleAccessByDepth extends Sprite
{
public function SampleAccessByDepth() {
var a:RectSprite = new RectSprite ("A", 0xB9121B);
var b:RectSprite = new RectSprite ("B", 0x4c1B1B);
var c:RectSprite = new RectSprite ("C", 0xF6E497);
var container:Sprite= new Sprite();
a.x = 100, a.y = 100;
b.x = 120, b.y = 120;
c.x = 140, c.y = 140;
//生成一个匿名的StarShape对象加入b中
b.addChild(new StarShape());
//加入显示列表
container.addChild(a);
container.addChild(b);
container.addChild(c);
addChild(container);
var star:Shape;
for (var i:int = 0; i<container.numChildren; i++) {
for ( var j:int = 0;
j<(container.getChildAt(i) as Sprite).numChildren;
j++ )
{
var tmpObj:DisplayObject =
(container.getChildAt(i) as Sprite).getChildAt(j);
if (tmpObj is StarShape) {
star = tmpObj as StarShape;
trace (i + "|" + j);
}
}
}
if (star != null) star.alpha = 0.5;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -