使用以下代码初始化数组dataFromFile(当我跟踪它时确实输出了正确的文件内容)“
var dataFromFile:Array;
var dataLoader:URLLoader = new URLLoader();
dataLoader.addEventListener(Event.COMPLETE, onLoaded);
dataLoader.load(new URLRequest("Data.txt"));
}
function onLoaded(e:Event):void
{
dataFromFile = e.target.data.split(/\n/);
trace(dataFromFile);
}
var dataFromFile:Array;
var sectionToLook:String = "[GAME]";
trace(dataFromFile[i1].toLowerCase());
trace(sectionToLook.toLowerCase());
trace("are equal:" + (dataFromFile[i1].toLowerCase() == sectionToLook.toLowerCase()));
trace("the type of data is:" + typeof(dataFromFile[i1]));
trace("the type of sectionData is:" + typeof(sectionToLook));
我得到的输出:
[游戏]
[游戏] 是平等的:假的 数据类型是:string sectionData的类型是:string
如果两个相同的字符串比较不相等,这怎么可能呢?