
541
EXTENDING FLASH PROFESSIONAL
C-Level Extensibility
Last updated 5/2/2011
Arguments
JSContext *cx, unsigned int length, jsval *v
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The length argument is the number of elements that the array can hold.
• The v argument is an optional pointer to the jsvals to be stored in the array. If the return value is not null, v is
an array that contains length elements. If the return value is
null, the initial content of the array object is undefined
and can be set using the
JS_SetElement() function.
Returns
A pointer to a new array object or the value null upon failure.
long JS_GetArrayLength()
Usage
long JS_GetArrayLength(JSContext *cx, JSObject *obj)
Description
Method; given a pointer to an array object, gets the number of elements in the array.
Arguments
JSContext *cx, JSObject*obj
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The obj argument is a pointer to an array object.
Returns
The number of elements in the array or -1 upon failure.
JSBool JS_GetElement()
Usage
JSBool JS_GetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp)
Description
Method; reads a single element of an array object.
Arguments
JSContext *cx, JSObject *obj, jsint idx, jsval *vp
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The obj argument is a pointer to an array object.
• The idx argument is an integer index into the array. The first element is index 0, and the last element is index
(
length 1-).
Komentáře k této Příručce