Skip to main content
Inspiring
Apr 24, 2022 4:21 PM UTC
Answered

cant place movie clip

so this is the function I have as of now 

function placeGem(x:int, y:int) {
	var newGemAmount:int = gems+1;
	var gemOBJ:RainbowGem = new RainbowGem();
	gemOBJ.x = x;
	gemOBJ.y = y;
	gemOBJ.name = "gem"+newGemAmount;
	gemOBJ.visible = true;
	background.addChild(gemOBJ);
	//gems++;
	trace("+----------------------------+");
	trace("| Gems name: "+ gemOBJ.name);
	trace("| Gems Y: "+ gemOBJ.y);
	trace("| Gem X: "+gemOBJ.x);
	trace("| Gems parent: "+gemOBJ.parent.name);
	trace("+----------------------------+");
	trace("\n");
}

 

and I get the right output* 

+----------------------------+
| Gems name: gem3
| Gems Y: 300
| Gem X: 440
| Gems parent: background
+----------------------------+

 

but the object is not being placed. "background" is a movie clip that is where I want "gemOBJ" to be in.

any idea why I don't see it being placed?

This topic is closed to new replies. Start a new post to keep the conversation going.
kglad
kgladCorrect answer
Community Expert
Apr 25, 2022 12:41 AM UTC

if on background 

+----------------------------+
| Gems name: gem3
| Gems Y: 0
| Gem X: 0
| Gems parent: background
+----------------------------+

 

and i see the gem, x&y must be screwed up I'm guessing?


background is probably messed up and should be at 0,0. 

 

if doing that moves background above and to the left of the stage (or, at least, where you want it), edit the background movieclip so it's reg point is at 0,0.

14 replies

kglad
Community Expert
Community Expert
Apr 24, 2022 11:47 PM UTC

background not being visible would do it as would several other things.

 

to see if it's a parent problem, try:

 

 

//background.addChild(gemOBJ);
stage.addChild(gemObj)

 

 

 

Translate
Inspiring
Apr 24, 2022 11:50 PM UTC

oddly that worked but i need it on the background movie clip

Translate
kglad
Community Expert
Community Expert
Apr 25, 2022 12:11 AM UTC

that's just for debugging and confirms you have a background problem.  eg, background is not on stage, or it's not visible or it's x,y is such that gemObj is off-stage etc.

 

it's easy to test for all these possibilities, using the trace statement.  if you need help, let me know.

Translate