This content has been marked as final. Show 5 replies
z-index is simply controlled by the order in which children are added (later children have a higher z-index). If you want to layer components, put them in a Canvas container and have their x,y coordinates overlap.
Thank you for your reply.
I understand how the z-index is determined. However, when I place an image "on top" on a panel by placing the tag after the panel's tag (and it's not contained within the panel as a result), It still seems like the image it "behind" the panel.
I'm not sure why you would be seeing that. Here's an example that works fine for me:
<mx:Panel x="0" y="0" width="250" height="200" layout="absolute" title="Hello World!"/>
<mx:Image x="30" y="0" source="someimage.png"/>
The image layers on top of the title just fine.
I think he means that the image is inside the component itself, not alongside the component in the same Canvas/Container.
If I understand correctly, you want to put an image inside the panel but have it "on top" of the Panel's title_mc sprite, is that right?
If I were to do something like this, I might use addChild() on the creationComplete event to guarantee that the image you are adding is placed later in the z-order than the auto-built title_mc.
Also, simply referencing the title_mc (have to check the name, but I think it's still called "title_mc") and then adding the image as a child of it, rather than the parent Panel might be a better solution. Refer to the code for Panel if this is what you are trying to do. By the way, this would be most easily done by subclassing Panel like you said.
>If I understand correctly, you want to put an image inside the panel but have it "on top" of the Panel's title_mc sprite, is that right?
That's what I was trying to do, yes. Eventually, I gave up thought I could simply drop the image ont top of the panel and be done with it.
In a new application it works like inlineblue stated, however, in my existing application (must be the various properties I've changed, that is doesn't seem like it's on top, because it gats "faded" a bit. Now that I'm writing this, I think it's probably because I have the alpha value set to 0.50 :)
>Refer to the code for Panel if this is what you are trying to do
Yes, I think I'm going to do that.