There are two types of objects for HTML collage display, the Htmlloader and the Stagewebview.
Htmlloader
The object Htmlloader is the most practical to deal with, as it works as a container for your HTML elements. You can add it as a child of any other DisplayObjectContainer
and more easily manipulate the content that is appearing, including accessing your Doms objects, just like Javascript does.
Below is a simple code of how the content is embedded within an object HTMLLoader
and display it on stage:
var hl:HTMLLoader = new HTMLLoader(); //Cria o Objeto HTMLLoader
hl.load(new URLRequest("http://www.google.com/")); //Carrega o conteúdo HTML, no caso, o site do Google
hl.addEventListener(Event.COMPLETE, completouLoader); //Adiciona o ouvinte COMPLETE
function completouLoader(e:Event):void {
trace("carregou página");
hl.width = stage.stageWidth; //Altera o Width e Height do objeto (Por padrão, estes valores possuem 0x0px)
hl.height = stage.stageHeight;
addChild(hl); //Adiciona o objeto na tela para exibir a página
}
Stagewebview
The Stagewebview works similar to the above object, but with functionality limited to Actionscript events and simpler. Not to mention that this object is plastered to the object Stage
of your application, which means that it will always be above any display object.
Follow an example display code:
var wv:StageWebView = new StageWebView(); //Cria o objeto
wv.viewPort = new Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight); //Configura o tamanho e local de exibição do conteúdo
wv.stage = this.stage; //Atrela ao objeto stage da sua aplicação
wv.loadURL("http://www.google.com"); //Carrega o conteúdo do site do Google
wv.addEventListener(Event.COMPLETE, carregou); //Ouvinte de evento Complete
wv.addEventListener(ErrorEvent.ERROR, erro); //Ouvinte de evento Erro
function carregou(e:Event):void {
trace("Carregou"); //Mais há mais nada a se fazer, após a página carregar toda ação é tomada pelo usuário ou pelos ouvintes disponibilizados pelo objeto "StageWebView"
}
function erro(e:ErrorEvent):void {
trace("Deu erro.");
trace(e);
}
These two objects work well in the Flash Professional, but according to the Adobe documentation, they are also compatible with Flex, which in turn has a class called Flexhtmlloader, in which I do not know, but probably should work similar to HTMLLoader
.
Thank you biio. Can you tell me if there is a component to be called by the page? Example: <Component:Htmlloader id="htmlloader"> ?
– RenatoMateusX
Sorry @Renatomateusx, honestly I have no knowledge in Flex, but I think something like this:
<mx:HTML id="HTMLLoader"/>
. Rsrs– bio