0
votes

I have a deep problem which I have encountered.

I am adding a movie clip inside to another movie clip and flash doesn't like this.

What I'm doing is dynamically adding a movieclip to a movieclip that hasn't been added dynamically.

movieclip 1

private var tim:player = new player();
//inside main
tim.addChild(ground);

now ground is an instance name that hasn't been added via code. It's on the stage in flash and it's a movievlip with the instance name ground.

What can I do to fix this please.

1

1 Answers

0
votes

Basically I wasn't really understanding As3,

From reading As3 101 - Display Lists I was able to understand that all things like sprites, shapes and movieclips are added to a display list.

In order to have added tim to a parent, that parent would have to be present.

This means that the parent would need to be added to the display list.

        addChild(container);

You can see that container is now part of the display list.

This means I can now:

            container.addChild(character);

Add the character to the container, and this now becomes a display object container

I can now trace what's in the container.

    trace(container.numChildren);

In this container there are 3 childrens, my ground, the player and the enemy :D