Skip to main content
Inspiring
April 24, 2022
Answered

cant place movie clip

  • April 24, 2022
  • 1 reply
  • 707 views

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 has been closed for replies.
Correct answer kglad

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.

1 reply

kglad
Community Expert
Community Expert
April 24, 2022

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)

 

 

 

Inspiring
April 24, 2022

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

kglad
Community Expert
Community Expert
April 25, 2022

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.