actionscript-3 - 如何将图像发送到 AS3 中

标签 actionscript-3

我想把太阳和阳光送到舞台后面:

function CreateRays():Shape
{
    var ray:Shape = new Shape();

    ray.graphics.beginFill(0xFF9900,.5);
    ray.graphics.lineStyle(1,0xFF9900,.5);
    ray.graphics.lineTo(600,-20);
    ray.graphics.lineTo(600,20);
    ray.graphics.lineTo(0,0);
    ray.graphics.endFill();

    return ray;
}

var sun:Shape = new Shape();

sun.graphics.beginFill(0xFF9900,1);
sun.graphics.drawCircle(0,0,30);
sun.graphics.endFill();

addChild(sun); 
setChildIndex(sun, 0); 

我看到 setChildIndex(sun, 0); 应该这样做,但它不起作用。

最佳答案

从您对添加对象的内容和您提供的代码语法的困惑来看,我猜您已经在顶级对象上了。试试这个:

this.addChildAt(sun,0);

这会将 sun 作为第一项添加到父对象(first = back,last = front)。如果我关于您当前所在的对象是正确的,它也应该是舞台上的第一个项目。

确保在使用它们之前阅读此类内容:DisplayObjectContainer.addChildAt()

关于actionscript-3 - 如何将图像发送到 AS3 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13016433/

相关文章:

php - 是否值得学习 C 来更深入地了解操作系统和计算机?

Flash 和本地主机环境。无法连接到真实网络?

flash - 动态地从我的 flash 库中获取一个类

actionscript-3 - 通过 AS3 字典进行高效循环

javascript - 为什么 YouTube JavaScript Player API 打开与我的代码中的 URL 不同的 URL,并且只播放播放列表的第一个视频?

apache-flex - 如何解压缩使用 ByteArray.compress 创建的 zlib 文件?

actionscript-3 - actionscript 3 如何在内联函数中访问 'this'

actionscript-3 - 如何获取当前活跃阶段?

flash - as3 事件 - 类型强制失败?

actionscript-3 - AS3 |从 URL 加载图像并开始拖动问题