Manipulação de folha de estilos HTML do ActionScriptAdobe AIR 1.0 e posterior Depois que o objeto HTMLLoader tiver despachado o evento complete, você poderá examinar e manipular estilos CSS na página. Por exemplo, considere o seguinte documento HTML simples: <html> <style> .style1A { font-family:Arial; font-size:12px } .style1B { font-family:Arial; font-size:24px } </style> <style> .style2 { font-family:Arial; font-size:12px } </style> <body> <p class="style1A"> Style 1A </p> <p class="style1B"> Style 1B </p> <p class="style2"> Style 2 </p> </body> </html> Depois que o objeto HTMLLoader carregar esse conteúdo, você poderá manipular os estilos CSS da página, através da matriz cssRules da matriz window.document.styleSheets, como mostrado a seguir: var html:HTMLLoader = new HTMLLoader( ); var urlReq:URLRequest = new URLRequest("test.html"); html.load(urlReq); html.addEventListener(Event.COMPLETE, completeHandler); function completeHandler(event:Event):void { var styleSheet0:Object = html.window.document.styleSheets[0]; styleSheet0.cssRules[0].style.fontSize = "32px"; styleSheet0.cssRules[1].style.color = "#FF0000"; var styleSheet1:Object = html.window.document.styleSheets[1]; styleSheet1.cssRules[0].style.color = "blue"; styleSheet1.cssRules[0].style.font-family = "Monaco"; } Esse código ajusta os estilos CSS para que o documento HTML resultante tenha a seguinte aparência: ![]() Lembre-se de que esse código pode adicionar estilos à página após o objeto HTMLLoader despachar o evento complete. |
![]() |