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

Countdown timer using AS3 not showing up in dynamic text box

New Here ,
Oct 04, 2023 Oct 04, 2023

Copy link to clipboard

Copied

Hello! I'm trying to make a countdown timer with AS3 in a dynamic text box to add to my timed puzzle game. The "100" simply won't show up in the text box. 

The code:

 

var nCount = 100;

timer_txt.text = nCount.toString();

 

I tried this exact same code in a new document, and it worked perfectly. However, in the file I'm editing, there's already a lot of extra (not DRY) code that I think is interferring with the timer.

I would copy paste my existing code but it's 1600+ lines and would clog up this post (happy to put the code up later if someone needed it). Any help would be appreciated!

 

TOPICS
ActionScript , Code , How to

Views

112

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 ,
Oct 05, 2023 Oct 05, 2023

Copy link to clipboard

Copied

is there an error message when testing?

 

if not, encode a trace statement that repeatedly polls your textfield's text.

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 ,
Oct 05, 2023 Oct 05, 2023

Copy link to clipboard

Copied

There wasn't an error message, and the trace returned "100" so it seems to work that way...

 

I commented out my existing code and tried it again - I'm following a tutorial and tried this code

var nCount: Number = 100;

var myTimer: Timer = new Timer(1000, nCount);

 

timer_txt.text = nCount.toString():

myTimer.start();

 

myTimer.addEventListener(TimerEvent.TIMER, countdown);

 

function countdown(e: TimerEvent): void {

    nCount--;

    timer_txt.text = nCount.toString():

}

 

which returned error 1009. I tested this code in a seperate document and it worked perfectly. Not sure what's going on, I'm new to AS3.

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 ,
Oct 05, 2023 Oct 05, 2023

Copy link to clipboard

Copied

Also, everything is on frame 1 so I don't understand why the function or variable (or something) can't be accessed

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 ,
Oct 06, 2023 Oct 06, 2023

Copy link to clipboard

Copied

LATEST

you're using colons where you should be using semi-colons.  those should all be generating errors (and not 1009 errors).

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