Copy link to clipboard
Copied
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/");
}
Copy link to clipboard
Copied
Hi.
Replace:
webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
By:
webView.viewPort = new Rectangle(0, 0, 320, 245);
Regards,
JC
Copy link to clipboard
Copied
Is there a way to centralize this function? For it is clinging to an edge.
Copy link to clipboard
Copied
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