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?
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.
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)
Copy link to clipboard
Copied
oddly that worked but i need it on the background movie clip
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.
Copy link to clipboard
Copied
sadly i do, i would not know hot to debug for this
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]]);
}
Copy link to clipboard
Copied
stage [object Stage]
visible true
alpha 1
x 329.8
y 235.65
Copy link to clipboard
Copied
what's the stage size? (eg, if it's 550x400, your gem is probably off-stage).
Copy link to clipboard
Copied
default AS3 size. 350x400
Copy link to clipboard
Copied
550 x 400*
Copy link to clipboard
Copied
use x,y = 0,0 for your gem to see the problem.
Copy link to clipboard
Copied
place gem on background or stage? also may I ask how that shows the problem?
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?
Copy link to clipboard
Copied
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.
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).