Packageqnx.events
Classpublic class JavaScriptCallbackEvent
InheritanceJavaScriptCallbackEvent Inheritance flash.events.Event

The QNXStageWebView object dispatches a JavaScriptCallbackEvent object when qnx.callExtensionMethod is called from QNXStageWebView's JavaScript.

There is only one type of JavaScriptCallbackEvent:

See also

QNXStageWebView


Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
Public Constants
 ConstantDefined By
  JAVA_SCRIPT_CALLBACK : String = javaScriptCallback
[static] Dispatched when a call has been made to the qnx.callExtensionMethod function in JavaScript.
JavaScriptCallbackEvent
Property Detail
nameproperty
name:String

Returns the name of the callback function that is being called.


Implementation
    public function get name():String
    public function set name(value:String):void
paramsproperty 
params:Array

Returns the parameters of the callback function. This array contains Strings.


Implementation
    public function get params():Array
    public function set params(value:Array):void
resultproperty 
result:String

Returns the result that will be returned to the caller (if the event is not cancelled).


Implementation
    public function get result():String
    public function set result(value:String):void
Constructor Detail
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.

Parameters
type:String
 
bubbles:Boolean (default = false)
 
cancelable:Boolean (default = false)
 
name:String (default = null)
 
params:Array (default = null)
 
result:String (default = null)
Method Detail
clone()method
override public function clone():Event

Duplicates 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.

Returns
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]

Returns
String
Constant Detail
JAVA_SCRIPT_CALLBACKConstant
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