htmlのテキストだけ抜く
package {
import flash.display.Sprite;
import flash.system.System;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldType;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
System.useCodePage=true;
var myLoader:URLLoader = new URLLoader();
//var myRequest:URLRequest = new URLRequest("http://www.google.co.jp/");
//myLoader.addEventListener(Event.COMPLETE, onComplete);
//myLoader.load(myRequest);
}
private function onComplete(e:Event):void {
urlReg(e.target.data);
}
private function urlReg(obj:Object):void {
var p1:RegExp = /<body.*>.*<\/body>/s;
var a:Array = String(obj).match(p1);
var s1:String = "";
for(var i:Number = 0;i<a.length;i++){
s1 += a[i];
}
var p2:RegExp = /<.*?>/g;
var s2:String = "";
var htmlStr:String = s1.replace(p2, s2);
var t:TextField = new TextField();
t.width = 470;
t.height = 320;
t.x = 15;
t.y = 15;
t.wordWrap =true;
t.border = true;
t.type = TextFieldType.DYNAMIC;
//t.autoSize=TextFieldAutoSize.LEFT
t.text = "aa";
addChild(t);
}
}
}