Skip to main content
Inspiring
January 22, 2020
Question

Size displayed on board <loadURL>

  • January 22, 2020
  • 1 reply
  • 420 views

I would like to know how I can define the size at which StageWebView information will be displayed on my stage.

Currently it occupies the entire stage, I would like to know how I can stay with the dimensions below:

width = 320 x height = 245

Thank you in advance, follow the code:

 

 

stage.scaleMode = StageScaleMode.NO_BORDER;

import flash.display.MovieClip;
import flash.media.StageWebView;
import flash.geom.Rectangle;
import flash.events.MouseEvent;

var webView: StageWebView = new StageWebView();

click.addEventListener(MouseEvent.CLICK, acc);

function acc (Event:MouseEvent) : void 
{
	webView.stage = this.stage;
	webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
	
	webView.loadURL("https://google.com/");
}

 

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
January 22, 2020

Hi.

 

Replace:

webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);

 

By:

webView.viewPort = new Rectangle(0, 0, 320, 245);

 

Regards,

JC

 

vvvverTAuthor
Inspiring
January 22, 2020

Is there a way to centralize this function? For it is clinging to an edge.

JoãoCésar17023019
Community Expert
Community Expert
January 23, 2020

If you want to center an object that has the origin point in the top left corner, use the following formula:

displayObject.x = (parent.width - displayObject.width) * 0.5;

displayObject.y = (parent.height- displayObject.height) * 0.5;

 

So your code would be:

webView.viewPort = new Rectangle((stage.stageWidth - 320) * 0.5, (stage.stageHeight - 245) * 0.5, 320, 245);

 

Regards,

JC