| Package | qnx.events |
| Class | public class JavaScriptCallbackEvent |
| Inheritance | JavaScriptCallbackEvent flash.events.Event |
QNXStageWebView object dispatches a JavaScriptCallbackEvent object when
qnx.callExtensionMethod is called from QNXStageWebView's JavaScript.
There is only one type of JavaScriptCallbackEvent:
JavaScriptCallbackEvent.JAVA_SCRIPT_RESULT: dispatched after a asynchronous JavaScript execution completes.See also
| Property | Defined By | ||
|---|---|---|---|
| name : String
Returns the name of the callback function that is being called. | JavaScriptCallbackEvent | ||
| params : Array
Returns the parameters of the callback function. | JavaScriptCallbackEvent | ||
| result : String
Returns the result that will be returned to the caller (if the event is not cancelled). | JavaScriptCallbackEvent | ||
| Method | Defined By | ||
|---|---|---|---|
JavaScriptCallbackEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, name:String = null, params:Array = null, result:String = null)
Creates a JavaScriptCallbackEvent object. | JavaScriptCallbackEvent | ||
clone():Event [override]
Duplicates an instance of an Event subclass. | JavaScriptCallbackEvent | ||
toString():String [override]
Returns a String that contains all the properties of the JavaScriptCallbackEvent object. | JavaScriptCallbackEvent | ||
| Constant | Defined By | ||
|---|---|---|---|
| JAVA_SCRIPT_CALLBACK : String = javaScriptCallback [static]
Dispatched when a call has been made to the qnx.callExtensionMethod function in JavaScript. | JavaScriptCallbackEvent | ||
| name | property |
name:StringReturns the name of the callback function that is being called.
public function get name():String public function set name(value:String):void| params | property |
params:ArrayReturns the parameters of the callback function. This array contains Strings.
public function get params():Array public function set params(value:Array):void| result | property |
result:StringReturns the result that will be returned to the caller (if the event is not cancelled).
public function get result():String public function set result(value:String):void| JavaScriptCallbackEvent | () | Constructor |
public function JavaScriptCallbackEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, name:String = null, params:Array = null, result:String = null)
Creates a JavaScriptCallbackEvent object.
type:String | |
bubbles:Boolean (default = false) | |
cancelable:Boolean (default = false) | |
name:String (default = null) | |
params:Array (default = null) | |
result:String (default = null) |
| clone | () | method |
override public function clone():EventDuplicates an instance of an Event subclass.
Returns a new Event object that is a copy of the original instance of the Event object.
You do not normally call clone(); the EventDispatcher class calls it automatically
when you redispatch an event—that is, when you call dispatchEvent(event) from a handler
that is handling event.
The new Event object includes all the properties of the original.
When creating your own custom Event class, you must override the
inherited Event.clone() method in order for it to duplicate the
properties of your custom class. If you do not set all the properties that you add
in your event subclass, those properties will not have the correct values when listeners
handle the redispatched event.
Event |
| toString | () | method |
override public function toString():String
Returns a String that contains all the properties of the JavaScriptCallbackEvent object.
The String is in the following format:
[JavaScriptCallbackEvent type=value bubbles=value
cancelable=value eventPhase=value name=value
params=value result=value]
String |
| JAVA_SCRIPT_CALLBACK | Constant |
public static const JAVA_SCRIPT_CALLBACK:String = javaScriptCallback
Dispatched when a call has been made to the qnx.callExtensionMethod function in JavaScript.
The QNXStageWebView object will automatically return the contents of the
result member (default null) unless you cancel this event. In that
case you must call sendJavaScriptCallbackReturnValue with the
result, the browser will wait and no further javaScriptCallback events will be received
until sendJavaScriptCallbackReturnValue is called.
The following listing shows a javascript function (in a web page) that calls the
qnx.callExtensionMethod() function:
<script type="text/javascript">
function close(){
qnx.callExtensionMethod("name","val1","val2");
//must have a parameter or else the event is not thrown, no includes are needed
}
</script>
Below, a callback function (in an actionscript class) is set up to capture the name and result of the javascript function.
webview.addEventListener(JavaScriptCallbackEvent.JAVA_SCRIPT_CALLBACK,function(event:JavaScriptCallbackEvent):void{
trace("callback complete");
trace("js name: " + event.name);//first parameter that was given
trace("js result: " + event.result);//null for the moment
for each(var object:String in event.params){
//rest of the parameters
trace(object);
}
}
See also