#1009 空对象引用(AS3、TextField)
我需要一些帮助(我是这个网站的新手)
我想要打字机效果。这样看起来字符串中的代码是逐字符键入的(对于动画)。然而,我得到了#1009 回复。它谈论空对象引用(错误是荷兰语)。
我的动态文本字段位于同一场景中的不同图层上。 codeTekst 是实例名称。这是经典的、充满活力的文本。多行行为并且未嵌入符号中。我正在使用 Flash CS5。这是我的代码:
import flash.utils.Timer;
import flash.events.TimerEvent;
var string:String = 'import flash.events.Event import flash.utils.Timer; import flash.events.TimerEvent; import flash.display.MovieClip; import flash.events.MouseEvent; import flash.media.Sound; import flash.media.SoundChannel; stop(); var beginSchermSpraak:Sound = new BeginSchermSpraak(); var beginSchermSpraakKanaal:SoundChannel = new SoundChannel(); var helpKnopSpraak:Sound = new HelpKnopSpraak(); var helpKnopSpraakKanaal:SoundChannel = new SoundChannel(); var eersteKeer:Boolean; var gebouw:uint; var vandaan:Boolean; var timer:Timer = new Timer(1, 1); splashMC.x=-9001; startKnop.x=-9001; if (eersteKeer == false) { splashMC.x=250; startKnop.x=250; beginSchermSpraakKanaal = beginSchermSpraak.play(); beginSchermSpraakKanaal.addEventListener(Event.SOUND_COMPLETE, helpKnopMaken); startKnop.addEventListener(MouseEvent.CLICK, startTimer); timer.addEventListener(TimerEvent.TIMER_COMPLETE, vervaag); } else {}';
var i:uint = 0;
var timer:Timer = new Timer(10);
timer.start();
timer.addEventListener(TimerEvent.TIMER, goTime);
function goTime(e:TimerEvent){
codeTekst.appendText(string.charAt(i));
i++;
if(i>=string.length) {
timer.stop();
}
}
感谢您的任何想法:)
I would like some help (and I'm new to this site)
I want a typewriter-effect. So that it looks like the code in the string is typed character by character (for an animation). However, I get a #1009 back. It talks about a null object reference (the error is in Dutch).
My dynamic text field is in the same scene, on a different layer. codeTekst is the instance name. It is classic, dynamic text. Multiline behaviour and not embedded in a symbol. I'm using Flash CS5. Here is my code:
import flash.utils.Timer;
import flash.events.TimerEvent;
var string:String = 'import flash.events.Event import flash.utils.Timer; import flash.events.TimerEvent; import flash.display.MovieClip; import flash.events.MouseEvent; import flash.media.Sound; import flash.media.SoundChannel; stop(); var beginSchermSpraak:Sound = new BeginSchermSpraak(); var beginSchermSpraakKanaal:SoundChannel = new SoundChannel(); var helpKnopSpraak:Sound = new HelpKnopSpraak(); var helpKnopSpraakKanaal:SoundChannel = new SoundChannel(); var eersteKeer:Boolean; var gebouw:uint; var vandaan:Boolean; var timer:Timer = new Timer(1, 1); splashMC.x=-9001; startKnop.x=-9001; if (eersteKeer == false) { splashMC.x=250; startKnop.x=250; beginSchermSpraakKanaal = beginSchermSpraak.play(); beginSchermSpraakKanaal.addEventListener(Event.SOUND_COMPLETE, helpKnopMaken); startKnop.addEventListener(MouseEvent.CLICK, startTimer); timer.addEventListener(TimerEvent.TIMER_COMPLETE, vervaag); } else {}';
var i:uint = 0;
var timer:Timer = new Timer(10);
timer.start();
timer.addEventListener(TimerEvent.TIMER, goTime);
function goTime(e:TimerEvent){
codeTekst.appendText(string.charAt(i));
i++;
if(i>=string.length) {
timer.stop();
}
}
Thanks for any ideas :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否检查过以确保文本字段在开始时不为空白? Flash 中有一个错误,因此您必须在框中包含一些文本,否则您将收到 null 错误。
还要确保嵌入字体。
Did you check to make sure the text field was not blank to start? There is a bug in flash, so you have to have some text in the box, or you will get the null error.
Also make sure you embed the font.
该代码对我来说运行良好;复制并粘贴到 Flash CS5 中。我所做的唯一一件事是添加一个 TextField 并为其指定一个实例名称“codeTekst”。您确定您的 TextField 实例在您的代码所在的框架上可用吗?
The code runs fine for me; Copied and pasted into Flash CS5. Only other thing I did was add a TextField and gave it an instance name of "codeTekst". Are you sure that your TextField instance is available on the frame that your code is on?