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

Components Problem

New Here ,
Jul 29, 2012 Jul 29, 2012

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?

TOPICS
ActionScript

Views

883

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 ,
Jul 29, 2012 Jul 29, 2012

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.)

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
New Here ,
Jul 29, 2012 Jul 29, 2012

Copy link to clipboard

Copied

TextFormat instances aren't labels? And labels dont have x and y?

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 ,
Jul 30, 2012 Jul 30, 2012

Copy link to clipboard

Copied

correct, TextFormat instances aren't labels.

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
New Here ,
Aug 04, 2012 Aug 04, 2012

Copy link to clipboard

Copied

ok i found the solution

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 ,
Aug 04, 2012 Aug 04, 2012

Copy link to clipboard

Copied

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

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
New Here ,
Aug 04, 2012 Aug 04, 2012

Copy link to clipboard

Copied

LATEST

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...

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