• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

282

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

Community Expert , 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.

Votes

Translate

Translate
Community Expert ,
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)

 

 

 

Votes

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

Votes

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
Community Expert ,
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.

Votes

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

 

 

Votes

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
Community Expert ,
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]]);
}

Votes

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

Votes

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
Community Expert ,
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).

Votes

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

Votes

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*

Votes

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
Community Expert ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

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

Votes

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?

Votes

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?

Votes

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
Community Expert ,
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.

Votes

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
Community Expert ,
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).

Votes

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