cant place movie clip

Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

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?

TOPICS
ActionScript , Code , Error

Views

208

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Apr 24, 2022 Apr 24, 2022
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.

Likes

Translate

Translate
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

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)

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

sadly i do, i would not know hot to debug for this

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

what's the output panel show with:

 

var propA:Array=["stage","visible","alpha","x","y"];

for(var i:int=0;i<propA.length;i++){
trace(propA[i], background[propA[i]]);
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

stage [object Stage]
visible true
alpha 1
x 329.8
y 235.65

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

what's the stage size?  (eg, if it's 550x400, your gem is probably off-stage).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

default AS3 size. 350x400

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

550 x 400*

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

use x,y = 0,0 for your gem to see the problem.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

place gem on background or stage? also may I ask how that shows the problem?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

replace your 

 

 placeGem(300, 440);

 

with

 

 placeGem(0,0)

 

and it shows the problem because you probably think that gem is going to be at the top left of your stage instead of where it will actually appear (below and to the right of stage center).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines