mardi 18 avril 2017

Error 1009 in AS3 Adobe Animate

I'm debugging my work, and later on, the "Error 1009" appears. I really don't know how to solve that error and tbh, I don't really understand the error that I've always encountered. So here's my code:

import flash.text.*;
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.DisplayObject;
import flash.geom.Point;
import flash.display.Stage;
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;

nohint.visible = false;
txtSkor.text = String(iskoru);
txtLives.text = String(buhay);
txtHints.text = String(hinto);


txtHint.visible = false;
var gamestage: int = 0;
var gameTimer:Timer = new Timer(1000);


gameTimer.addEventListener(TimerEvent.TIMER, countDown);


gameTimer.start();
function countDown(event: TimerEvent): void {
  **txtSec.text = String(sec);**
  sec--;
  if (sec < 0) {
  gameTimer.stop();
  gameTimer.removeEventListener(TimerEvent.TIMER, countDown);
  maliWin.visible = true;
  quizquest.visible = false;
  ans11.visible = false;
  ans12.visible = false;
  ans13.visible = false;
  btnHint.visible = false;
  tim.visible = false;
  }


  ans11.addEventListener(MouseEvent.CLICK, buttones1);
  ans12.addEventListener(MouseEvent.CLICK, buttones2);
  ans13.addEventListener(MouseEvent.CLICK, buttones3);


  function buttones1(event: MouseEvent): void {
  corekWin.visible = true;
  iskoru += 10;
  //txtSkor.text = String(iskoru);
  trace("click successful");
  }
  function buttones2(event: MouseEvent): void {
  maliWin.visible = true;
  buhay -= 1;
  //txtLives.text = String(buhay);
  trace("click successful");
  }


  function buttones3(event: MouseEvent): void {
  maliWin.visible = true;
  buhay -= 1;
  //txtLives.text = String(buhay);
  trace("click successful");
  }
  maliWin.btnGobak.addEventListener(MouseEvent.CLICK, bey);


  function bey(event: MouseEvent): void {
  maliWin.visible = false;
  }


  corekWin.btnGo.addEventListener(MouseEvent.CLICK, gura);


  function gura(event: MouseEvent): void {
  corekWin.visible = false;
  quizquest.visible = false;
  ans11.visible = false;
  ans12.visible = false;
  ans13.visible = false;
  btnHint.visible = false;
  txtSec.visible = false;
  tim.visible = false;
  playergril.visible = true;
  stage.addEventListener(Event.ENTER_FRAME, loofa);
  }
}
function loofa(event: Event): void {
  if (doorOpen == false) {
  if (playergril.hitTestObject(pinto)) {
  pinto.gotoAndStop(2);
  playergril.visible = false;
  doorOpen = true;
  trace("door open");
  gotoAndStop(77);
  }
  }
}
btnHint.addEventListener(MouseEvent.CLICK, wee);
function wee(event: MouseEvent): void {
  hinto -= 1;
  txtHint.visible = true;
  if (hinto == 0) {
  nohint.visible = true;
  }
}

Note: the line with two asterisks each side is the main cause of it or pointed error.

And the error says:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
  at RECOVER_dmgamedemover_fla::MainTimeline/countDown()[RECOVER_dmgamedemover_fla.MainTimelin e::frame76:27]
  at flash.utils::Timer/_timerDispatch()
  at flash.utils::Timer/tick()

When I look at the side (Debug Console) contains some variables and objects. The other dynamic texts have been declared (flash.text.TextField) while the txtSec, the another dynamic text, is null. I have no idea on what's going on it. What would be the best solution for it? Any suggestions or ideas are appreciated. Thanks!

Aucun commentaire:

Enregistrer un commentaire