views:

480

answers:

4

The subject pretty much explains it all. I start on frame one of a MovieClip with just a Bitmap covering the whole stage.

Then when a user clicks a button, it goes to frame two and a vector shape is on the stage covering part of the image. At the same time, through code, I place an input Textfield on the stage.

Problem is, the dynamically created Textfield is appearing UNDER the vector shape (which was drawn on the stage)! This seems to be a problem that is new to ActionScript 3, as I did not have this problem with Flash CS3 and ActionScript 2.

I've tried putting the Textfield on different layers, but to no avail. How do I get the Textfield to appear over the vector shape?

A: 

Put the vector shape inside a movieclip. Then call:

setChildIndex(myTextField, numChildren - 1);
Iain
A: 

I've already tried that. It's wacky stuff like this that's keeping me from migrating my frameworks to AS 3.

I have determined that the issue somehow lies in the way that Flash renders what is on the stage. When calling some_mc.play(); introduces new objects to the stage -- while at the same time programmatically placing other objects on the stage -- the objects that were hand-placed on the stage will always render directly on top of any programmatically created objects. This might not be everyone's experience, but that is what I am seeing.

My solution: call some_mc.play();, wait 10ms and then place other objects on the stage.

Jeremy White
A lack of understanding does not make something wacky.
Tegeril
A: 

You can try adding the vector shape through code and then add the textfield.

var vectorShape:Sprite = new Sprite();  
addChild(vectorShape);

var textField:TextField = new textField();  
addChild(textField);

That would put the vector shape below the textfield.

Paul Sheldrake
A: 

It sounds like your trouble arises because the design-time vector and the runtime text field come into existence in the same frame, so it's a timing issue where they appear and when you can move them.

The easiest thing might be to avoid this problem. One way would be to create an empty movie clip (on the stage, at design time) to be a holder for the text field, layer it wherever you want, and create the text inside of it at runtime. Another solution would be to create either the vector or the text field (or both) in frame 1, but keep it/them invisible until necessary.

fenomas