AS3 在帧之间显示数据
我有一个用 AS3 编写的 Android Air 项目,当项目启动时,我正在加载音乐并加载要解析的 XML 文件。在第一帧中,我调用我的类来解析 XML 并将节点设置为字符串,并播放音频,这些都工作得很好。另外,在我的第一帧中,我声明了一些文本字段来输入 XML 文件中的数据,以便当用户输入第 3 帧时,用户能够看到 XML 文件中的数据。这也很好用。我遇到的问题是在第 4 帧之间返回到第 3 帧,文本字段中的数据消失了?我跟踪保存数据的 XML 类中的字符串,这些值每次都会出现,但是从第 3 帧到第 4 帧再返回到第 3 帧会清除文本字段显示吗?有人能指出我正确的方向吗? 谢谢 科学
好的,这里是第一帧中的一些代码,我在其中声明文本字段
var name1TextField:TextField = new TextField();
var name2TextField:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = "_sans";
format.color = 0xF8FBF8;
format.size = 36;
//set the names format to the textfields
name1TextField.defaultTextFormat = format;
name2TextField.defaultTextFormat = format;
highScore1.addChild(name1TextField);
highScore2.addChild(name2TextField);
这是调用 XML 解析类并将文本设置到节点的代码
var network:networkScores = new networkScores();
addChild(network);
var timer4:Timer = new Timer(600);
timer4.addEventListener(TimerEvent.TIMER, scoresDis);
timer4.start();
function scoresDis(e:TimerEvent):void
{
name1TextField.text = network.name1;
name2TextField.text = network.name2;
//trace(name1TextField.text);
//trace(name2TextField.text);
name1TextField.width = 230;
name2TextField.width = 230;
timer4.stop();
}
前面,上面我已经说过我从第一个调用音频类和 xml 类框架,声明文本字段并从那里继续。现在我决定,由于这个 XML 文件是一个分数列表,并且编码总是在变化,所以我认为每次进入第 3 帧时加载和解析这个文件会很好。同样的事情仍然发生,我的分数显示然后当我转到第 4 帧并返回到第 3 帧时,分数不会显示,但当我跟踪班级数据时,它会正确显示。 谢谢 科学的
I have a Android Air project written in AS3, when the project starts I am loading the music and loading the XML file to be parsed. In the first frame I call my classes to parse the XML and set the nodes at strings, and to play the audio, these both work fine. Also in my first frame I am declaring some textfields to input the data from the XML file so that when the user enters frame 3 the user is able to see this data from the XML file. This also works fine. The problem I am having is going between frame 4 and back to frame 3, the data in the textfields disapears? I trace the strings from the XML class that are holding the data and these values appear everytime, but going from frame 3 to frame 4 and back to frame 3 wipes out the textfield display? Can anyone point me in the right direction?
thanks
Scientific
Ok here is some code from frame one where I am declaring the textfields
var name1TextField:TextField = new TextField();
var name2TextField:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = "_sans";
format.color = 0xF8FBF8;
format.size = 36;
//set the names format to the textfields
name1TextField.defaultTextFormat = format;
name2TextField.defaultTextFormat = format;
highScore1.addChild(name1TextField);
highScore2.addChild(name2TextField);
Here is the code calling the XML parsing class and setting the text to the nodes
var network:networkScores = new networkScores();
addChild(network);
var timer4:Timer = new Timer(600);
timer4.addEventListener(TimerEvent.TIMER, scoresDis);
timer4.start();
function scoresDis(e:TimerEvent):void
{
name1TextField.text = network.name1;
name2TextField.text = network.name2;
//trace(name1TextField.text);
//trace(name2TextField.text);
name1TextField.width = 230;
name2TextField.width = 230;
timer4.stop();
}
Previously above I had stated that I am calling the audio class and the xml class from the first frame, declaring the text fields and moving on from there. Now I have decided that since this XML file is a list of scores and coded be always changing, I thought it would be good to load and parse this file everytime I enter frame 3. The same thing is still happening, I have my scores display and then when I go to frame 4 and back to frame three, the scores do not display, but when I trace the data from the class, it displays properly.
Thanks
Scientific
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前见过这个问题发生在不正确的嵌入字体或其他东西上,我记不清了。测试这一点的快速方法是也追踪字段的 .text 属性。这样,当文本不可见时,如果字段的 .text 属性仍然填充,那么您就知道遇到了渲染问题。
进行此快速测试并发布结果,我将根据结果用更多信息更新我的答案。
I've seen this issue happen before with improperly embedded fonts or something, I can't recall exactly. A quick way to test this would be to trace out the .text property of the fields too. This way, when the text isn't visible, if the .text property of the field is still populated then you know you've got a rendering problem.
Do this quick test and post the results, I'll update my answer with more information depending on the outcome.