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

error 1067: Implicit coercion of a value of type int to an unrelated type String.

New Here ,
Nov 02, 2011 Nov 02, 2011

Copy link to clipboard

Copied

im making a game and i have occured a problem.i have a hits text on the screen and every time a enemys bullet hits me it decrases by 1.and i wanna make that when it gets to 0 my ship explodes.

Dont know how to do it.tryed this

package com.asgamer.basics1

{

 

          import flash.display.MovieClip;

          import flash.display.Stage;

          import flash.text.TextField;

          import flash.events.Event;

 

          public class ScoreHUD extends MovieClip

          {

 

                    private var stageRef:Stage;

                    public var s_score:Number = 0;

                    public var s_hits:Number = 100;

                    public var s_kills:Number = 0;

 

                    public function ScoreHUD(stageRef:Stage)

                    {

 

                              this.stageRef = stageRef;

 

                              kills.text = "0";

                              hits.text = "100";

                              score.text = "0";

 

                              x = 10;

                              y = stageRef.stageHeight - height - 10;

 

                    }

 

                    public function updateKills(value:Number) : void

                    {

                              s_kills += value;

                              kills.text = String(s_kills);

                    }

 

                    public function updateHits(value:Number) : void

                    {

                              s_hits += value;

                              hits.text = String(s_hits);

                              }

 

                    public function updateScore(value:Number) : void

                    {

                              s_score += value;

                              score.text = String(s_score);

                    }

                    public function loop(e:Event) : void{

                    if (hits.text = 0){stageRef.addChild(new SmallImplosion(stageRef, x, y));} // this is where i get the error

 

          }

 

}

}

i get this error 1067: Implicit coercion of a value of type int to an unrelated type String.

TOPICS
ActionScript

Views

4.3K

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 ,
Nov 02, 2011 Nov 02, 2011

Copy link to clipboard

Copied

use:

package com.asgamer.basics1 
{
  
          import flash.display.MovieClip;
          import flash.display.Stage;
          import flash.text.TextField;
          import flash.events.Event;
  
          public class ScoreHUD extends MovieClip
          {
  
                    private var stageRef:Stage;
                    public var s_score:Number = 0;
                    public var s_hits:Number = 100;
                    public var s_kills:Number = 0;
  
                    public function ScoreHUD(stageRef:Stage) 
                    {
  
                              this.stageRef = stageRef;
  
                              kills.text = "0";
                              hits.text = "100";
                              score.text = "0";
  
                              x = 10;
                              y = stageRef.stageHeight - height - 10;
  
                    }
  
                    public function updateKills(value:Number) : void
                    {
                              s_kills += value;
                              kills.text = String(s_kills);
                    }
  
                    public function updateHits(value:Number) : void
                    {
                              s_hits += value;
                              hits.text = String(s_hits);
                              }
  
                    public function updateScore(value:Number) : void
                    {
                              s_score += value;
                              score.text = String(s_score);
                    }
                    public function loop(e:Event) : void{
                    if (hits.text == "0"){stageRef.addChild(new SmallImplosion(stageRef, x, y));} // this is where i get the error
  
          }
  
}
}
 

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 ,
Nov 03, 2011 Nov 03, 2011

Copy link to clipboard

Copied

no error now but nothing happens.Any help?

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 ,
Nov 03, 2011 Nov 03, 2011

Copy link to clipboard

Copied

LATEST

use the trace() function to see what's in your hits textfield.  ie, make sure it's not html-enabled, kerning is disabled and its single line.

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