StageWebView DataEvent.WEBVIEW_MESSAGE not triggering #3669
Unanswered
hahmann1979
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
In the below code I have the 'javascriptResponseHandler' function that should receive a message from the postMessage from the html when touched, but it's not triggering, am I missing something??
AS3:
import flash.media.StageWebView;
import flash.geom.Rectangle;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.desktop.NativeApplication;
import flash.events.DataEvent
import flash.events.*;
var WebView:StageWebView;
WebView = new StageWebView(true);
WebView.addEventListener(DataEvent.WEBVIEW_MESSAGE,javascriptResponseHandler );
WebView.addEventListener(Event.LOCATION_CHANGE,changed );
WebView.viewPort = null;
WebView.loadURL('https://www.silas-admin.eu/webpagetest/');
WebView.stage = this.stage;
WebView.viewPort = new Rectangle(0 ,0, stage.fullScreenWidth / 2, stage.fullScreenHeight);
WebView.addEventListener(DataEvent.WEBVIEW_MESSAGE,javascriptResponseHandler );
function javascriptResponseHandler(e:DataEvent){
trace('something coming back.....');
trace(e.data);
}
function changed(e:Event){
trace('different!!!')
}
sample html:
<title>Basic HTML5 document</title> <style> body{ width:100vw; height:100vh; } </style>Test
<script> document.body.addEventListener('click' , function (e) { console.log('touched!'); window.chrome.webview.postMessage('webViewMessage'); }, false); </script>Beta Was this translation helpful? Give feedback.
All reactions