Skip navigation
Pettas
Currently Being Moderated

Components Problem

Jul 29, 2012 10:28 AM

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?

 
Replies
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 29, 2012 11:28 AM   in reply to Pettas

    textformat instances don't have x and y properties.

     

    (and i'm not sure it makes sense to create all those textformat instances.)

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 30, 2012 7:28 AM   in reply to Pettas

    correct, TextFormat instances aren't labels.

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 4, 2012 12:46 PM   in reply to Pettas

    mark the thread as answered, post the problem and mark helpful/correct messages.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points