Thank you for your answer Laurent.

I was doing something similar, but more complicated: calling
addChild(sprite) in createChildren() and then setting the index of the
sprite to numChildren - 1 in updateDisplayList.

Apparently the answer is to wrap the sprite in a UIComponent and adding that
using addChild() (idea taken from
http://casario.blogs.com/mmworld/2008/01/adding-a-sprite.html).

I think the problem was that setting the position and size of the sprite
using its x, y, width and height properties didn't work as expected. And,
although I was setting the sprite to be as large as its parent, it had no
effect (from the docs: "Except for TextField and Video objects, a display
object with no content (such as an empty sprite) has a width of 0, even if
you try to set width to a different value.").

Now, using move() and setActualSize() on the wrapper UIComponent does the
trick. It works even without adding the sprite and drawing directly on the
wrapper.

However, this raises another question: it seems that resizing the
UIComponent containing the Sprite, also resizes the Sprite; why wasn't the
Sprite resized when adding it directly to the component?

Alex

On Fri, Feb 20, 2009 at 4:20 PM, Laurent Cozic <pogopix...@yahoo.com> wrote:

>   > I have tried using a Sprite as the topmost child and drawing on it
>
> I think that's the way to do it. To make sure that your  sprite is always
> on top, just add "addChild(yourSprite)" at the end of the updateDisplayList
> function. If the sprite is not on the display list, it's going to be added
> to it, and if it's already there, it's going to be pushed on top of all the
> other sprites.
>
>

Reply via email to