Quantcast
Channel: Adobe Community : Popular Discussions - Archived Discussions
Viewing all articles
Browse latest Browse all 21156

Display stage webview on new screen/stage or frame when button clicked

$
0
0

I'm trying to get Stagewebview to show on a new stage when a button is clicked.  Right now it just shows on the same stage  becuase code is this.stage.

 

Also, when it shows up on the new page I want to have back button, forward, and refresh and I want it on the top and not taking alot of space and only on the screen where it's showing the web view.

 

Please help!!!!!!!!!!

 

Here is the code:

 

stop();

import flash.display.StageAlign;

import flash.display.StageScaleMode;

import flash.events.MouseEvent;

import flash.net.URLRequest;

import flash.media.StageWebView;

import flash.geom.Rectangle;

 

stage.align = StageAlign.TOP_LEFT;

 

stage.scaleMode = StageScaleMode.NO_SCALE;

 

var webView:StageWebView;

 

var swvRect:Rectangle;

 

var swvHeight:Number;

 

var uiElemsTop:Number=140;

 

var swvY:Number=140;

 

var uiElemsBot:Number=40+20+75+20;

 

var uiElemsHeight:Number=uiElemsTop+uiElemsBot;

 

infoBox.text="";

 

infoBox.visible=false;

 

mainPanel.visible=false;

 

webBtnsPanel.visible=false;

 

mcStart.addEventListener(MouseEvent.CLICK,init);

 

 

function init(e:MouseEvent):void {

 

    mcStart.removeEventListener(MouseEvent.CLICK,init);

 

    mcStart.visible=false;

 

    mainPanel.btnExit.addEventListener(MouseEvent.CLICK, exitApp);

 

    mainPanel.btnCloseSwv.addEventListener(MouseEvent.CLICK,closeSwv);

 

    mainPanel.btnOpenSwv.addEventListener(MouseEvent.CLICK, openSwv);

 

    infoBox.text="Click open stage web view to begin";

 

    webBtnsPanel.btnNext.addEventListener(MouseEvent.CLICK, nextPage);

 

    webBtnsPanel.btnPrev.addEventListener(MouseEvent.CLICK, prevPage);

 

    webBtnsPanel.btnReload.addEventListener(MouseEvent.CLICK, reloadPage);

 

    webBtnsPanel.btnStop.addEventListener(MouseEvent.CLICK, stopPage);

 

    swvHeight=stage.stageHeight-uiElemsHeight;

 

    infoBox.x=stage.stageWidth/2-infoBox.width/2;

 

    infoBox.y=stage.stageHeight-40;

 

    mainPanel.x=stage.stageWidth/2-mainPanel.width/2;

 

    webBtnsPanel.x=stage.stageWidth/2-webBtnsPanel.width/2;

 

    webBtnsPanel.y=140+swvHeight+20;

 

    mainPanel.visible=true;

 

    infoBox.visible=true;

}

 

//When the user taps on Exit button, the app quits.

 

 

function exitApp(event:MouseEvent):void {

 

    NativeApplication.nativeApplication.exit(0);

}

 

function closeSwv(event:MouseEvent):void {

 

    if(webView==null){

 

        return;

    }

 

     webView.removeEventListener(ErrorEvent.ERROR,onError);

 

     webView.removeEventListener(LocationChangeEvent.LOCATION_CHANGING,onC hanging);

 

     webView.removeEventListener(Event.COMPLETE,onComplete);

 

     webView.viewPort=null;

     webView.dispose();

     webView=null;

 

     webBtnsPanel.visible=false;

 

     infoBox.text="Click open stage web view to begin";

}

 

function openSwv(event:MouseEvent):void {

 

    if(webView!=null){

 

        return;

    }

 

     webBtnsPanel.visible=true;

 

     infoBox.text="";

 

     webView=new StageWebView();

 

     webView.stage= next.stage;

 

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

 

     webView.addEventListener(ErrorEvent.ERROR,onError);

 

     webView.addEventListener(LocationChangeEvent.LOCATION_CHANGING,onChan ging);

 

     webView.addEventListener(Event.COMPLETE,onComplete);

 

     webView.loadURL("http://www.math.uri.edu/~bkaskosz/webview/index.html");

}

 

function onError(e:ErrorEvent):void {

 

    infoBox.text="Page is not available. Try reloading.";

 

}

 

function onChanging(e:LocationChangeEvent):void {

 

    infoBox.text="Loading...";

 

}

 

function onComplete(e:Event):void {

 

    infoBox.text="";

 

}

 

function nextPage(e:MouseEvent):void {

 

    if(webView==null){

 

        return;

    }

 

    if(!webView.isHistoryForwardEnabled){

 

        return;

    }

 

    webView.historyForward();

 

}

 

function prevPage(e:MouseEvent):void {

 

    if(webView==null){

 

        return;

    }

 

    if(!webView.isHistoryBackEnabled){

 

        return;

    }

 

    webView.historyBack();

 

}

 

function reloadPage(e:MouseEvent):void {

 

    if(webView==null){

 

        return;

    }

 

    webView.reload();

 

}

 

function stopPage(e:MouseEvent):void {

 

    if(webView==null){

 

        return;

    }

 

    webView.stop();

 

}

 

Message was edited by: nelljonesatl


Viewing all articles
Browse latest Browse all 21156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>