如何在 FlashBuilder 中使用外部动作脚本类(我以为我知道)
我正在尝试在 Air 应用程序中实现 CSVLib,但收到一个对我来说似乎完全不合逻辑的错误。
“1120:访问未定义的属性 csv。” 和 “1120:访问未定义的属性completeHandler。”
我唯一能想到的是它没有正确导入 csv 类,或者类本身以某种方式被破坏了?我知道我的导入路径是正确的,因为我是根据自动提示直接输入的。下面的代码直接从 csv lib 站点上的操作 wiki 复制。
或者您需要做一些特殊的事情才能使外部动作脚本类在 flashbuilder 中工作?
<fx:Script>
<![CDATA[
import com.shortybmc.*;
import com.shortybmc.data.parser.CSV;
var csv:CSV = new CSV();
csv.addEventListener (Event.COMPLETE, completeHandler);
csv.load (new URLRequest('example-2.csv'));
function completeHandler (event: Event)
{
trace ( csv.data.join('\r') );
// do something ...
}
]]>
</fx:Script>
I'm trying to implement CSVLib in an Air application and am getting an error that seems wholly illogical to me.
"1120: Access of undefined property csv."
and
"1120: Access of undefined property completeHandler."
The only thing I can think is it's not importing the csv class properly, or the class itself is broken somehow? I know my import path is correct because I typed it out directly based on automatic hinting. The code below is copied directly from the how-to wiki on the csv lib site.
Or is there something special you need to do to get external actionscript classes to work in flashbuilder?
<fx:Script>
<![CDATA[
import com.shortybmc.*;
import com.shortybmc.data.parser.CSV;
var csv:CSV = new CSV();
csv.addEventListener (Event.COMPLETE, completeHandler);
csv.load (new URLRequest('example-2.csv'));
function completeHandler (event: Event)
{
trace ( csv.data.join('\r') );
// do something ...
}
]]>
</fx:Script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,问题出在其他地方。
fx:Script
标记位于 MXML 文件中,它表示类定义。发生错误是因为您在类定义中有代码(即在方法之外)。例如,您可以这样写:
然后您需要确保实际上调用了
init
方法;您可以在 MXML 对象的完整处理程序中执行此操作。In this case, the problem is somewhere else. The
fx:Script
tag is within a MXML file, which represents a class definition.Your error happens, because you have code within the class definition (i.e. outside of a method). You can write this instead for example:
Then you need to make sure that the
init
method is actually called; you can do this in the complete handler of your MXML object.