标签:style io for ar cti div new size
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
public class Test extends Sprite {
var textField:TextField;
var arrDirty:Array;
var arrName:Array;
public function Test() {
textField = new TextField();
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, OnComTxtComplete);
loader.load(new URLRequest("dirty_words_config.txt"));
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, OnComXmlComplete);
xmlLoader.load(new URLRequest("random_name.xml"));
}
private function OnComXmlComplete(e:Event):void
{
var xml:XML = new XML(e.target.data);
arrName = new Array();
var name:XML;
for each (name in xml.random_firstname.element)
{
var firstName:String = name.@m_firstName;
arrName.push(firstName);
}
for each (name in xml.random_name_m.element)
{
var lastNameMan:String = name.@m_lastName;
if (lastNameMan != "")
{
arrName.push(lastNameMan);
}
}
for each (name in xml.random_name_w.element)
{
var lastNameWomen:String = name.@m_lastName;
if (lastNameWomen != "")
{
arrName.push(lastNameWomen);
}
}
var iDirty:int;
var iName:int;
var iSzName:int;
var iSzDirty:int;
var szDirty:String;
var szName:String;
for(iName = 0; iName < arrName.length; ++iName)
{
for(iDirty = 0; iDirty < arrDirty.length; ++iDirty)
{
szName = arrName[iName];
szDirty = arrDirty[iDirty];
if(szName.indexOf(szDirty) >= 0)
{
trace(szName + " " + szDirty);
break;
}
/* for(iSzName = 0; iSzName < szName.length; ++iSzName)
{
for(iSzDirty = 0; iSzDirty < szDirty.length; ++iSzDirty)
{
var tmpName:String = szName.charAt(iSzName);
var tmpDirty:String = szDirty.charAt(iSzDirty);
if(tmpName == tmpDirty)
{
trace("单词相同 szName:" + szName + " szDirty:" + szDirty);
trace(iName + " " + iDirty + " " + iSzName + " " + iSzDirty);
}
}
}*/
}
}
trace("done");
}
private function OnComTxtComplete(e:Event):void
{
textField.text = e.target.data;
arrDirty = new Array();
arrDirty = textField.text.split("\r");
}
}
}
as3 读取XML和txt,布布扣,bubuko.com
as3 读取XML和txt
标签:style io for ar cti div new size
原文地址:http://www.cnblogs.com/loying/p/3904419.html