我该如何定义什么是层的孩子正在创建使用Flash CS5 AS3的时候到? [英] How can I define what a layer a child is created onto when using Flash CS5 AS3?

查看:157
本文介绍了我该如何定义什么是层的孩子正在创建使用Flash CS5 AS3的时候到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示一个孩子在2层我将如何使用AS3,动态地在第2帧创建一个孩子?

I need to display a child on layer 2. How would I, using AS3, dynamically create a child on frame 2?

推荐答案

图层2是不够具体。什么什么的显示对象容器的层?

"Layer 2" isn't specific enough. What layer of what display object container?

下面是显示列表编程要说明一个很好的文章启发。

Here is a good article on display list programming that should prove enlightening.

要回答你的问题,你将确定父displayObject的,并调用它的addChild方法,与您的目标子DisplayObject作为参数。如果你的父母DisplayObject是含有类(扩展的DisplayObject,雪碧,例如一个类),你可以调用addChild()或this.addChild()。要增加孩子的一层除了最上面,则可以使用addChildAt()。

To answer your question, you would identify the parent displayObject and call its addChild method, with your targeted child displayobject as the parameter. If your parent displayObject is the containing class (a class that extends DisplayObject, a Sprite, for example), you can just call addChild() or this.addChild(). To add the child at a layer other than the topmost, you can use addChildAt().

        var someclip:Sprite = new Sprite();
        var someOtherClip:Sprite = new Sprite();
        var yetAnotherClip:Sprite = new Sprite();
        var someLibrayClip:LibraryClip = new LibraryClip();

        this.addChild(someClip);
        this.addChildAt(someOtherClip,0);
        someOtherClip.addChild(yetAnotherClip);
        someOtherClip.addChildAt(someLibrayClip,0);
        etc...

请注意,该显示列表是一个堆栈一样的阵列,并在其情况下,可能不包含空索引。如果你想在2层的东西,还必须有项目在0和1。

Note that the display list is a stack like an array, and in its case, may not contain empty indexes. If you want something in layer 2, there must also be items in 0 and 1.

希望有所帮助 -

这篇关于我该如何定义什么是层的孩子正在创建使用Flash CS5 AS3的时候到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆