How to use Stagewebview

Asked

Viewed 74 times

1

I need to implement an Application to show HTML texts already formatted, these texts are with images.

I found two options: Webview - But I can’t use it as a component, just instantiating and playing on screen. Richeditabletext, this works 100% as I want, however, Scrollbar does not work on mobile, and tests on emulator, works only when scrolling the mouse scroll button

Does anyone know how to solve?

1 answer

1


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 HTMLLoaderand 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"> ?

  • Sorry @Renatomateusx, honestly I have no knowledge in Flex, but I think something like this: <mx:HTML id="HTMLLoader"/>. Rsrs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.