AS3错误:“1172:定义fl.controls:按钮找不到” [英] AS3 Error: '1172: Definition fl.controls:Button could not be found.'
问题描述
我想创建一个类LinkButton的,这是加载一个网址上点击一个简单的类的(我这样做是为了simpify我的设计师过渡到AS3)的。即使我导入按钮定义,AS文件获取编译错误: 1046:类型找不到或不是编译时间常数:按钮的和< STRONG> 1172:定义fl.controls:按钮找不到的我通过一个简单的形状,将其转换为符号的类型(F8)按钮创建的按钮。在我的FLA文件我有这个code:
I am trying to create a class called LinkButton, which is a simple class that loads a URL on a click (im doing this to simpify my designers' transition to AS3). Even though I am importing the button definition, the AS file gets a compile error: 1046: Type was not found or was not a compile-time constant: Button. and 1172: Definition fl.controls:Button could not be found. I created the button by making a simple shape converting it to a symbol (F8) of type 'Button'. In my FLA file i have this code:
import AS3classes.mouse.LinkButton;
var link1:LinkButton = new LinkButton(testLink, "http://www.example.com");
简单吧?在我作为文件,我导入按钮定义,声明构造函数和'linkTo行为。这是我的code在AS文件:
Simple right? In my AS file I am importing the button definition, declaring the constructor and 'linkTo' Behaviour. Here is my code in the AS file:
package AS3classes.mouse
{
import fl.controls.Button;
import flash.events.*;
import flash.net.*;
public class LinkButton
{
private var _pageURL:String;
private var _button:Button;
public function LinkButton(button, pageURL) : void
{
_button = button;
_pageURL = pageURL;
_button.addEventListener(MouseEvent.MOUSE_UP, LinkTo);
}
private function LinkTo(e:Event) : void
{
var request:URLRequest = new URLRequest(_pageURL);
}
}
}
当我google一下,我看到有人收到此错误,因为他们没有在他们的库中的按钮。我有一个按钮,我从一个简单的形状创建。我是否导入正确的定义是什么?我没有问题,用同样的方法输入在不同的脚本中的动画片段定义。我不明白的差别,我pretty的肯定,我不傻。
When I Google this, I see people getting this error because they don't have a button in their library. I do have a button I created from a simple shape. Am I importing the right definition? I have no problem importing the movieClip definition in a different script with the same method. I don't understand the difference, and I'm pretty sure I'm not stupid.
推荐答案
您使用了错误类型的按钮。当你形容的话,你想
You are using the wrong type of button. As you describe it, you want
flash.display.SimpleButton
fl.controls.Button
是一个按钮组件,而不是在库中定义的按钮。合理?尝试导入flash.display.SimpleButton和设置_button是为SimpleButton代替。
fl.controls.Button
is a Button component, not a button defined in the library. Make sense? Try importing flash.display.SimpleButton and setting _button to be a SimpleButton instead.
这篇关于AS3错误:“1172:定义fl.controls:按钮找不到”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!