【问题标题】:Flash Timer Issue闪光定时器问题
【发布时间】:2014-04-06 13:46:23
【问题描述】:

所以我正在尝试在 Flash 中创建一个计时器,只是一个基本计时器。我在 Google 上查看了一些教程,发现了一些不错的教程。我遇到的问题是当我尝试在不同的屏幕上创建计时器时。我已经制作了动态文本框myText。当我尝试访问myText 时,它给了我Game Screen, Layer 'AS3', Frame 156, Line 11, Column 2 1120: Access of undefined property myText.

这是我的代码在调用计时器时的样子:

import flash.utils.Timer;
import flash.events.TimerEvent;

var count :Number=60;
var myTimer :Timer=new Timer(1000, count);
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.start();

function countdown(event:TimerEvent):void
{
    myText.text=String((count)-myTimer.currentCount);
}

我已按照教程进行了 T 并不断遇到问题。 Am I creating the text box wrong? Do I need to add the text box to the screen I want it on? Do I need to create a movie clip with the text box in it?我不确定我做错了什么,任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: actionscript-3 flash timer


    【解决方案1】:

    我是否需要将文本框添加到我想要的屏幕上?

    是的。作为错误状态,您的文本字段无法在关键帧到达,您在其中放置了带有计时器的代码。此外,如果您在所需的关键帧上已经有文本字段,我想您忘了给它命名,请检查这一刻。

    【讨论】:

    • 好吧,我好像明白了。我没有在顶部的代码中启动它。我在代码顶部添加了public var myText :TextField,现在它可以正常工作了!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-02
    • 1970-01-01
    • 2011-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多