Copy link to clipboard
Copied
Hey guys, i have this code:
var square:Sprite = new Sprite();
addChild(square);
square.graphics.beginFill(0xFFFFFF);
square.graphics.drawRect(0,0,100,100);
square.graphics.endFill();
square.alpha = 1;
square.x = mouseX;
square.y = mouseY;
var itemname:TextFormat = new TextFormat;
itemname.x = square.x + 10;
itemname.y = square.y + 10;
itemname.color = "0xFFFFFF";
itemname.text = phpVar1;
/*var iconimage:UILoader = new UILoader;
iconimage.source = phpVar2;
iconimage.x = square.x/3;
iconimage.y = square.x + 20;*/
if(phpVar3 != "0"){
var armor:TextFormat = new TextFormat;
itemname.x = square.x + 10;
itemname.y = square.y + 30;
itemname.color = "0xFFFFFF";
itemname.text = phpVar3;
}
if(phpVar4 != "0"){
var damage:TextFormat = new TextFormat;
itemname.x = square.x + 10;
itemname.y = square.y + 40;
itemname.color = "0xFFFFFF";
itemname.text = phpVar4;
}
if(phpVar5 != "0"){
var critical:TextFormat = new TextFormat;
itemname.x = square.x + 10;
itemname.y = square.y + 50;
itemname.color = "0xFFFFFF";
itemname.text = phpVar5;
}
if(phpVar6 != "0"){
var life:TextFormat = new TextFormat;
itemname.x = square.x + 10;
itemname.y = square.y + 60;
itemname.color = "0xFFFFFF";
itemname.text = phpVar6;
}
var story:TextFormat = new TextFormat;
itemname.x = square.x + 10;
itemname.y = square.y + 70;
itemname.color = "0xFFFFFF";
itemname.text = phpVar7;
But the output says that
Access of possibly undefined property [some property] through a reference with static type flash.text:TextFormat. |
Whats wrong?
Copy link to clipboard
Copied
textformat instances don't have x and y properties.
(and i'm not sure it makes sense to create all those textformat instances.)
Copy link to clipboard
Copied
TextFormat instances aren't labels? And labels dont have x and y?
Copy link to clipboard
Copied
correct, TextFormat instances aren't labels.
Copy link to clipboard
Copied
ok i found the solution
Copy link to clipboard
Copied
mark the thread as answered, post the problem and mark helpful/correct messages.
Copy link to clipboard
Copied
I created the instances in the enviroment insted of code and i managed them also from them properties instead of code, i cant really remember what i was doing wrong...