htmlsprite是一个Flash用来解析HTML文档的开发包。
示例代码:
importcom.redurba.HTMLSpritevarhtmlsprite:HTMLSprite=ewHTMLSprite();////staticdebugmodeo/offHTMLSprite.debug=true;////Usethisevetwheloadigbothstylesheetadhtmlfilehtmlsprite.addEvetListeer(HTMLSprite.LOADCOMPLETE,LoadComplete);////Thisevetwillbedispatchedwhetherederigiscompletehtmlsprite.addEvetListeer(HTMLSprite.RENDERCOMPLETE,RederComplete);////Usethisevetwheloadigastylesheetfileoly//Willbedispatchedwhetheloadiscompleted.htmlsprite.addEvetListeer(HTMLSprite.STYLECOMPLETE,StyleComplete);////Usethisevetwheloadigaexteralhtmlfileoly,//Willbedispatchedwhetheloadiscompleted.htmlsprite.addEvetListeer(HTMLSprite.HTMLCOMPLETE,HtmlComplete);////Thisevetwillbedispatchedwheaexterallikisclick//<ahref="evet:iteralEvet">Example</a>htmlsprite.addEvetListeer(HTMLSprite.LINK,Lik); //Examplehtmlfile+cssfile//htmlsprite.Load("html/idexwithoutcss.htm","html/style.css"); //Examplestylesheetfileoly//htmlsprite.LoadStylesheet("html/style.css"); //Examplehtmlfileoly//htmlsprite.Load("html/idex.htm"); //Examplehtmltext+stylesheettextvarstylesheet:StyleSheet=ewStyleSheet();stylesheet.setStyle(".header",{fotFamily:"Arial",color:"#000000"});stylesheet.setStyle("body",{fotFamily:"Arial"});stylesheet.setStyle("div",{fotFamily:"Arial",fotSize:"20px",backgroudColor:"#efefef"});htmlsprite.stylesheet=stylesheet;htmlsprite.html="Hello<br/>world!";htmlsprite.Reder();////LikListeerpublicfuctioLik(evt:LikEvet){varlikType:Strig=evt.data.type;varlikValue:Strig=evt.data.value;varlikTarget:Strig=evt.data.target; trace("liktype:"+likType+",likvalue:"+likValue+",liktarget:"+likTarget);}////LoadCompleteListeer//It'simportatthatyourederthehtmlafterthestylesheet//adhtmlfilehasbeeloadedpublicfuctioLoadComplete(evt:Evet){htmlsprite.Reder();}//LoadStylesheetComplete//DootusethislisteerwheyouuseaexteralstylesheetANDexteralHTML.//YoucausethetheLoadCompleteExamplepublicfuctioStyleComplete(evt:Evet){htmlsprite.html="hello<br/>world";htmlsprite.Reder();}//LoadHTMLComplete//DootusethislisteerwheyouuseaexteralstylesheetANDexteralHTML.//YoucausethetheLoadCompleteExample publicfuctioHtmlComplete(evt:Evet){htmlsprite.stylesheet=stylesheet;htmlsprite.Reder();} //Redercomplete//Atthispoitit'ssafetodetermiewidthadheightofthesprite//adaddittothedisplaylistpublicfuctioRederComplete(evt:Evet){addChild(htmlsprite);}
评论