Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Regular Contributor
Posts: 82
Registered: ‎11-12-2010
My Device: Android Droid Incredible

Re: QNXStageWebView - pass values or call functions between ActionScript and JavaScript?

Use qnx.callExtensionMethod as follows:

 

1) add the event listener to the webview object for javascriptcallback

2) qnx.callExtensionMethod( "test", "val","num");

 

the extension method can be called from javascript but MUST have a parameter or the javascriptcallback event is not thrown. In the above example "test" is the javascriptcallback's name property and after that you have an array of values. In this example javascriptcallback's params or "values" would be ["val","num"].

 

Once again if you don't specify any parameters, no event is thrown.

Regular Contributor
Posts: 93
Registered: ‎02-03-2011
My Device: Not Specified

Re: QNXStageWebView - pass values or call functions between ActionScript and JavaScript?

Thanks so much.  After 2 months since this item was started we have the answer.  Also I found this link that gives a bit more detail to the method:

 

http://blog.vayen.ch/2011/04/02/qnxstagewebview-and-qnx-callextensionmethod/

 

Jim

 

Contributor
Posts: 20
Registered: ‎03-22-2011
My Device: playbook and 9800

Re: QNXStageWebView - pass values or call functions between ActionScript and JavaScript?

u throw the string using qnx call extension methohd like this
<script type="text/javascript">
function nwpn(){
qnx.callExtensionMethod("http://www.adobe.com");
}

</script>
write this javascript code in html and call the java script function in html .than collect the string which u throw usin this action script code ..

import mx.events.FlexEvent;
import qnx.events.JavaScriptCallbackEvent;
import qnx.media.QNXStageWebView;
public var webview:QNXStageWebView=new QNXStageWebVi();
protected function button1_clickHandler(event:MouseEvent):void
{

// TODO Auto-generated method stub
webview.viewPort=new Rectangl(300,300,1024,600);
webview.stage=this.stage;
webview.enableJavaScript=true;
webview.enableCrossSiteXHR=true;
webview.enablePlugins=true;
webview.enableResourceFiltering=true;
webview.addEventListener(JavaScriptCallbackEvent.JAVA_SCRIPT_CALLBACK,_callback);
webview.loadURL("https://www.google.com");
}
protected function _callback(event:JavaScriptCallbackEvent) : void
{
var action:smileyfrustrated:tring=event.name; //this will contain the value which u throw from qnx.callextensionmethod
l.text=action;
navigateToURL(new URLRequest(action));
}