as3 - COMPILER ERROR 1120:访问未定义的属性* 7

时间:2012-02-28 20:09:58

标签: actionscript-3 flash flash-cs5 flash-cs4

错误&消息来源:

1120: Access of undefined property projectsNum.
projectsNum = projectTitle.length();

1120: Access of undefined property newsTitleArray.
newsTitleArray = xmlData.news.article.title.text().toXMLString().split("\n") ;

1120: Access of undefined property newsTitleArray.
newsTitleArray.reverse();

1120: Access of undefined property newsInfoArray.
newsInfoArray = xmlData.news.article.info.text().toXMLString().split("\n") ;

1120: Access of undefined property newsInfoArray.
newsInfoArray.reverse();

1120: Access of undefined property newsContentArray.
newsContentArray = xmlData.news.article.Content.text().toXMLString().split("\n") ;

1120: Access of undefined property newsContentArray.
newsContentArray.reverse();

我的XML操作我怀疑错误的操作是:

//XML LISTS//
//=========//

var projectTitle:XMLList;
var projectAuthor:XMLList;
var projectImage:XMLList;
var projectProgz:XMLList;
var projectHyper:XMLList;

var newsTitle:XMLList;
var newsInfo:XMLList;
var newsContent:XMLList;

var projectNum:Number;
var newsNum:Number;

var xml:XMLLoader = new XMLLoader(this,"data.xml");

function getXML(xmlData:XML):void {

    projectTitle = xmlData.projects.project.Title;
    projectAuthor = xmlData.projects.project.Author;
    projectImage = xmlData.projects.project.image_path;
    projectProgz = xmlData.projects.project.Progz;
    projectHyper = xmlData.projects.project.link;

    newsTitle = xmlData.news.article.title;
    newsInfo = xmlData.news.article.info;
    newsContent = xmlData.news.article.content;

    projectsNum = projectTitle.length();
    newsNum = newsTitle.length();

    newsTitleArray = xmlData.news.article.title.text().toXMLString().split("\n") ;
    newsTitleArray.reverse();

    newsInfoArray = xmlData.news.article.info.text().toXMLString().split("\n") ;
    newsInfoArray.reverse();

    newsContentArray = xmlData.news.article.content.text().toXMLString().split("\n") ;
    newsContentArray.reverse();

}

the source files files

并且我没有发布任何其他代码因为我不知道错误可能在哪里但我已经上传the source files files如果你需要它们

1 个答案:

答案 0 :(得分:0)

当您看到错误时:

  

1120:访问未定义的属性'VariableName'。

这意味着您没有定义或声明变量(或作为对象/类的属性访问它时的函数)。以下是概述:

1120: Access of undefined property projectsNum.
projectsNum = projectTitle.length();  // You have declared [var projectNum:Number;] Error source = s --> project[s]Num [Reason #1] 

1120: Access of undefined property newsTitleArray. // I do not see a declaration for this variable [Reason #2]
newsTitleArray = xmlData.news.article.title.text().toXMLString().split("\n") ;

1120: Access of undefined property newsTitleArray. // [Reason #2]

newsTitleArray.reverse();

1120: Access of undefined property newsInfoArray. // [Reason #2]

newsInfoArray = xmlData.news.article.info.text().toXMLString().split("\n") ;


1120: Access of undefined property newsInfoArray. // [Reason #2]

newsInfoArray.reverse();


1120: Access of undefined property newsContentArray. // [Reason #2]

newsContentArray = xmlData.news.article.Content.text().toXMLString().split("\n") ;


1120: Access of undefined property newsContentArray. // [Reason #2]

newsContentArray.reverse();

对我来说似乎是一个简单的错误。我希望这会有所帮助。