-
[RESOLVED] mc.stage.addChild vs mc.addChild
I have the followings:
_p:Player (which is a MC)
a1:Animation1 (which is a MC)
_p.addChild(a1); //doesn't display anything
_p.stage.addChild(a1); //displays a1
Why won't the MC display a child without using his stage?
-
_p is probably moved off the visible area or otherwise set invisible (visible = false or alpha = 0). Or a1 is placed such that when it is relative to _p's coordinate system it is off the viewable area.
-
trace(_p.visible, _p.x, _p.y, _a1.x, _a1.y, _a1.visible);
true 100 250 100 250 true
So it is visible and should be seen.
I thought maybe it was because I made the var a1:Animation1 in a function so it didn't keep the var once function is done but then I 've put it in the class (changed name to _a1) properties so it should stay there.
Also want to add that I'm addchilding to the MC from a 3rd party class.
Is there some limitations on adding childs directly to a mc froma 3rd class or should it work normally?
-
Senior Member
What is _p a child of? The stage itself?
-
Originally Posted by Alluvian
What is _p a child of? The stage itself?
It's from the document (main) class. I guess it means it's from stage?
-
There is something I can't tell going on. I don't really fully understand your setup. Can you post full code, or at least all relevant excerpts? There should be no difference between adding A to B from one class vs another.
-
Senior Member
trace(_p.visible, _p.x, _p.y, _a1.x, _a1.y, _a1.visible);
true 100 250 100 250 true
Adding _a1 as a child of _p would put _a1 at x:200, y:500 globally, is that visible? I don't know the size of your stage.
-
Originally Posted by Alluvian
trace(_p.visible, _p.x, _p.y, _a1.x, _a1.y, _a1.visible);
true 100 250 100 250 true
Adding _a1 as a child of _p would put _a1 at x:200, y:500 globally, is that visible? I don't know the size of your stage.
A quick try to _a1.y = 100 made it visible so you were right.
I didn't guess that tracing .x .y of a mc is relative to his parent.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|