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

Error 1084 Expecting rightparen before colon

Explorer ,
Feb 19, 2016 Feb 19, 2016

Anyone knows why am I getting this error? All brackets are closed.

if (s_score(value:Number) < 10000)

TOPICS
ActionScript
896
Translate
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 ,
Feb 19, 2016 Feb 19, 2016

you have a syntax error.

use:

if (s_score(value) < 10000)

Translate
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
Explorer ,
Feb 20, 2016 Feb 20, 2016

Thanks, I tried, but then I got error 1180 and 1120. I'm actually using the tutorial from Scores, HUDs, and User Interface | Flash Game Development Tutorials - As Gamer to create my own version of shooting game (there is a download link for the whole game, including a few more as files). The tutorial comes with 1 enemy (Stinger) and 1 level, it also comes with a score system, so I'm trying to create more enemies (Stinger 2 and 3) and levels. I'm able to add more enemies to the array, and want to make them only spawn between specific scores. Here's the original game engine.as coding:

  1. package com.asgamer.basics1
  2. {
  3.   import flash.display.MovieClip;
  4.   import flash.display.Stage;
  5.   import flash.events.Event;
  6.   public class Engine extends MovieClip
  7.   {
  8.   private var numStars:int = 80;
  9.   public static var enemyList:Array = new Array();
  10.   private var ourShip:Ship;
  11.   private var scoreHUD:ScoreHUD;
  12.   public function Engine() : void
  13.   {
  14.   ourShip = new Ship(stage);
  15.   ourShip.x = stage.stageWidth / 2;
  16.   ourShip.y = stage.stageHeight / 2;
  17.   ourShip.addEventListener("hit", shipHit, false, 0, true);
  18.   stage.addChild(ourShip);
  19.   scoreHUD = new ScoreHUD(stage);
  20.   stage.addChild(scoreHUD);
  21.   for (var i:int = 0; i < numStars; i++)
  22.   {
  23.   stage.addChildAt(new Star(stage), stage.getChildIndex(ourShip));
  24.   }
  25.   addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
  26.   }
  27.   private function loop(e:Event) : void
  28.   {
  29.   if (Math.floor(Math.random() * 90) == 5)
  30.   {
  31.   var enemy:Stinger = new Stinger(stage, ourShip);
  32.   enemy.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
  33.   enemy.addEventListener("killed", enemyKilled, false, 0, true);
  34.   enemyList.push(enemy);
  35.   stage.addChild(enemy);
  36.   }
  37.   }
  38.   private function enemyKilled(e:Event)
  39.   {
  40.   scoreHUD.updateKills(1);
  41.   scoreHUD.updateScore(e.currentTarget.points);
  42.   }
  43.   private function removeEnemy(e:Event)
  44.   {
  45.   enemyList.splice(enemyList.indexOf(e.currentTarget), 1);
  46.   }
  47.   private function shipHit(e:Event)
  48.   {
  49.   scoreHUD.updateHits(1);
  50.   }
  51.   }
  52. }

And here's the original scoreHUD.as coding:

  1. package com.asgamer.basics1
  2. {
  3.   import flash.display.MovieClip;
  4.   import flash.display.Stage;
  5.   import flash.text.TextField;
  6.   import flash.events.Event;
  7.   public class ScoreHUD extends MovieClip
  8.   {
  9.   private var stageRef:Stage;
  10.   public var s_score:Number = 0;
  11.   public var s_hits:Number = 0;
  12.   public var s_kills:Number = 0;
  13.   public function ScoreHUD(stageRef:Stage)
  14.   {
  15.   this.stageRef = stageRef;
  16.   kills.text = "0";
  17.   hits.text = "0";
  18.   score.text = "0";
  19.   x = 10;
  20.   y = stageRef.stageHeight - height - 10;
  21.   }
  22.   public function updateKills(value:Number) : void
  23.   {
  24.   s_kills += value;
  25.   kills.text = String(s_kills);
  26.   }
  27.   public function updateHits(value:Number) : void
  28.   {
  29.   s_hits += value;
  30.   hits.text = String(s_hits);
  31.   }
  32.   public function updateScore(value:Number) : void
  33.   {
  34.   s_score += value;
  35.   score.text = String(s_score);
  36.   }
  37.   }
  38. }

I've made changes to the game engine.as but not the scoreHUD.as, here's my version:

  1. package objects
  2. {
  3.   import flash.display.MovieClip;
  4.   import flash.display.Stage;
  5.   import flash.events.Event;
  6.   public class Engine extends MovieClip
  7.   {
  8.   private var numStars:int = 80;
  9.   public static var enemyList:Array = new Array();
  10.   private var ourShip:Ship;
  11.   private var scoreHUD:ScoreHUD;
  12.   public function Engine() : void
  13.   {
  14.   ourShip = new Ship(stage);
  15.   ourShip.x = stage.stageWidth / 2;
  16.   ourShip.y = stage.stageHeight / 2;
  17.   ourShip.addEventListener("hit", shipHit, false, 0, true);
  18.   stage.addChild(ourShip);
  19.   scoreHUD = new ScoreHUD(stage);
  20.   stage.addChild(scoreHUD);
  21.   for (var i:int = 0; i < numStars; i++)
  22.   {
  23.   stage.addChildAt(new Star(stage), stage.getChildIndex(ourShip));
  24.   }
  25.   addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
  26.   }
  27.   private function loop(e:Event) : void
  28.   {
  29.   if (s_score(value) < 10000)
  30.   {
  31.   if (Math.floor(Math.random() * 60) == 5)
  32.   {
  33.   var enemy:Stinger = new Stinger(stage, ourShip);
  34.   enemy.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
  35.   enemy.addEventListener("killed", enemyKilled, false, 0, true);
  36.   enemyList.push(enemy);
  37.   stage.addChild(enemy);
  38.   var enemy2:Stinger2 = new Stinger2(stage, ourShip);
  39.   enemy2.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
  40.   enemy2.addEventListener("killed", enemyKilled, false, 0, true);
  41.   enemyList.push(enemy2);
  42.   stage.addChild(enemy2);
  43.   var enemy3:Stinger3 = new Stinger3(stage, ourShip);
  44.   enemy3.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
  45.   enemy3.addEventListener("killed", enemyKilled, false, 0, true);
  46.   enemyList.push(enemy3);
  47.   stage.addChild(enemy3);
  48.   }
  49.   }
  50.   }
  51.   private function enemyKilled(e:Event)
  52.   {
  53.   scoreHUD.updateKills(1);
  54.   scoreHUD.updateScore(e.currentTarget.points);
  55.   }
  56.   private function removeEnemy(e:Event)
  57.   {
  58.   enemyList.splice(enemyList.indexOf(e.currentTarget), 1);
  59.   }
  60.   private function shipHit(e:Event)
  61.   {
  62.   scoreHUD.updateHits(1);
  63.   }
  64.   }
  65. }

In my version, line 44 - 63 is the enemies spawn control, I added line 40, 41, 64 so these enemies only spawn when player's score is below 10000, I was going to set another wave of enemies for 10001 - 20000 to increase the difficulty, but obviously I have to fix these errors first.

Translate
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 ,
Feb 20, 2016 Feb 20, 2016
LATEST

your original question is answered.  this thread should be closed.  that you have more errors is not related to your original question. 

once a compiler error is corrected, further errors may be discovered by the compiler.  you may have many errors even beyond the additional two you posted.

so you need a method to correct your errors, or in computer parlance, to debug your code.

with actionscript in animate/flash pro, start by clicking file>publish settings>swf and tick 'permit debugging'.  retest.

the problematic line numbers with their errors will be in the error message allowing you quickly find your error and correct it.  if you need help correcting the error(s), you can post in the adobe forums and ask for help.

but don't post 87 lines of code and ask us to debug it.  pinpoint the problematic code like you did in your first message.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Translate
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