htmlsprite Flash的HTML解析开源项目

我要开发同款
匿名用户2010年03月01日
49阅读
开发技术ActionScript
所属分类Web应用开发、HTML解析器
授权协议GPLv2

作品详情

htmlsprite是一个Flash用来解析HTML文档的开发包。

示例代码:

importcom.redurban.HTMLSpritevarhtmlsprite:HTMLSprite=newHTMLSprite();////staticdebugmodeon/offHTMLSprite.debug=true;////Usethiseventwhenloadingbothstylesheetandhtmlfilehtmlsprite.addEventListener(HTMLSprite.LOADCOMPLETE,LoadComplete);////Thiseventwillbedispatchedwhentherenderingiscompletehtmlsprite.addEventListener(HTMLSprite.RENDERCOMPLETE,RenderComplete);////Usethiseventwhenloadingastylesheetfileonly//Willbedispatchedwhentheloadiscompleted.htmlsprite.addEventListener(HTMLSprite.STYLECOMPLETE,StyleComplete);////Usethiseventwhenloadingaexternalhtmlfileonly,//Willbedispatchedwhentheloadiscompleted.htmlsprite.addEventListener(HTMLSprite.HTMLCOMPLETE,HtmlComplete);////Thiseventwillbedispatchedwhenanexternallinkisclick//<ahref="event:internalEvent">Example</a>htmlsprite.addEventListener(HTMLSprite.LINK,Link);                       //Examplehtmlfile+cssfile//htmlsprite.Load("html/indexwithoutcss.htm","html/style.css");                       //Examplestylesheetfileonly//htmlsprite.LoadStylesheet("html/style.css");                       //Examplehtmlfileonly//htmlsprite.Load("html/index.htm");                       //Examplehtmltext+stylesheettextvarstylesheet:StyleSheet=newStyleSheet();stylesheet.setStyle(".header",{fontFamily:"Arial",color:"#000000"});stylesheet.setStyle("body",{fontFamily:"Arial"});stylesheet.setStyle("div",{fontFamily:"Arial",fontSize:"20px",backgroundColor:"#efefef"});htmlsprite.stylesheet=stylesheet;htmlsprite.html="Hello<br/>world!";htmlsprite.Render();////LinkListenerpublicfunctionLink(evt:LinkEvent){varlinkType:String=evt.data.type;varlinkValue:String=evt.data.value;varlinkTarget:String=evt.data.target;                       trace("linktype:"+linkType+",linkvalue:"+linkValue+",linktarget:"+linkTarget);}////LoadCompleteListener//It'simportantthatyourenderthehtmlafterthestylesheet//andhtmlfilehasbeenloadedpublicfunctionLoadComplete(evt:Event){htmlsprite.Render();}//LoadStylesheetComplete//DonotusethislistenerwhenyouuseanexternalstylesheetANDexternalHTML.//YoucanusethentheLoadCompleteExamplepublicfunctionStyleComplete(evt:Event){htmlsprite.html="hello<br/>world";htmlsprite.Render();}//LoadHTMLComplete//DonotusethislistenerwhenyouuseanexternalstylesheetANDexternalHTML.//YoucanusethentheLoadCompleteExample               publicfunctionHtmlComplete(evt:Event){htmlsprite.stylesheet=stylesheet;htmlsprite.Render();}               //Rendercomplete//Atthispointit'ssafetodeterminewidthandheightofthesprite//andaddittothedisplaylistpublicfunctionRenderComplete(evt:Event){addChild(htmlsprite);}

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论