addChild(); - 将影片剪辑添加到 AS3 中的帧
我正在尝试创建一个函数,在框中添加一个文本框(蓝色矩形)和一个文本字段。我在库中有一个名为 textBox 的类,没有使用外部类。 我大约一个月前开始使用 ActionScript 3(甚至在学习许多编程基础知识之前),所以我对此没有经验。
function createTextBox() {
var textBoxCoordX:int = 305;
var textBoxCoordY:int = 80;
var dialogueBox:textBox = new textBox;
var dialogueText:TextField = new TextField();
addChild(dialogueBox);
dialogueBox.x = textBoxCoordX;
dialogueBox.y = textBoxCoordY;
dialogueText.x = textBoxCoordX+5;
dialogueText.y = textBoxCoordY+5;
dialogueText.text = "Insert Text Here";
}
玩完后,我立即收到两个错误,将我链接到“varDialogueBox:textBox = new textBox;”这些错误的描述为“1046:未找到类型或不是编译时常量:textBox。”和“1180:调用可能未定义的方法textBox。”
I am trying to create a function which adds a text box (a blue rectangle) and a textfield on the box. I have a class in the library named textBox, no external classes used.
I started actionscript 3 (before even learning many of the programming fundamentals) about a month ago, so I am not experienced with this.
function createTextBox() {
var textBoxCoordX:int = 305;
var textBoxCoordY:int = 80;
var dialogueBox:textBox = new textBox;
var dialogueText:TextField = new TextField();
addChild(dialogueBox);
dialogueBox.x = textBoxCoordX;
dialogueBox.y = textBoxCoordY;
dialogueText.x = textBoxCoordX+5;
dialogueText.y = textBoxCoordY+5;
dialogueText.text = "Insert Text Here";
}
After playing, I immediately get two errors that link me to "var dialogueBox:textBox = new textBox;" These errors' descriptions say "1046: Type was not found or was not a compile-time constant: textBox." and "1180: Call to a possibly undefined method textBox."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保已设置联动。右键单击,高级,勾选导出为 ActionScript。
Ensure that the linkage is set. Right click, advanced, tick Export for ActionScript.
我认为找不到文本框电影剪辑,
您必须确定该库具有 movieClips 和名为 textBox 的链接名称。
i think no find textBox movieclip,
You must determine the library has the movieClips and the linkedname called textBox.