AS3错误#1009 [英] AS3 error #1009

查看:125
本文介绍了AS3错误#1009的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当我运行以下代码时,出现错误#1009,表示var'list'为null?
有人可以告诉我此AS3代码有什么问题吗,我已经进行了大量搜索和阅读了大量信息,但是无论代码多么简单,它仍然是#1009问题.
谢谢,


When I run the following code I get a error #1009 saying that the var 'list' is null?
Can someone please tell me what's wrong with this AS3 code, I've done lots of searching and read lot of info but no matter how simple the code it's still the same erro #1009 issue.
Thanks,

package  
{  
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    public class Main extends Sprite
    {    
        public var list:Array;

        public function Main() {  
            stage.addEventListener(MouseEvent.CLICK, add);
        }

        public function add(e:MouseEvent):void {
            list.push("ball");
            trace(list);
        } 
    }  
}

推荐答案

未初始化.

public var list:Array = [];

public var list:Array = new Array();

这篇关于AS3错误#1009的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆