Hi,
first some notes for array elements:
- array elements can be accessed by their name or a numeric index
- when the first character of the indexname is a number then this number is interpreted as index (0 based)
- otherwise the element is accessed by the given name
- try to avoid mixing of numeric and names as index when defining array items in the xml!
here a example - how to get the name of each array item with the krpano interface:
(AS3 code / JS similar)
|
Quellcode
|
1
2
3
4
5
6
7
8
9
|
var count:int = int( krpano.get("plugin.count") );
var i:int;
for (i=0; i<count; i++)
{
var itemname:String = krpano.get("plugin[" + i + "].name");
// ...
// all other attributes can be accessed by the same way
}
|
this is the standard way via the krpano interface, this works identically also in javascript!
but with AS3 - there is also a more advanced and faster access possible

an Array in krpano is of the internal type "
Kinterface_array",
this Array can by accessed as "
Object" in AS3,
how to use it:
first get the internal array object via the krpano interface:
|
Quellcode
|
1
|
var krpanoarray:Object = krpano.get("plugin");
|
this
Kinterface_array object has the following attributes and interface functions:
attributes:
- count
- the number of elements in this array
- could be changed by setting it, but warning - only reducing the size is possible (e.g. set to 0 to clear the array), increasing the count would have a undefined behavior!
functions:
- createItem(name:String):*
- creates a new array item with the given name
- returns the new item object
- getItem(name:String):*
- returns the item object or null if not found
- when name is a numeric value - the name is interpreted as index (0 ... count-1)
- getItemIndex(index:int):*
- direct index access (faster than getItem)
- returns the item object or null if not found
- getArray():Array
- returns a AS3 Array object of all array items
- note - this Array object can be used for reading/modify items, but the Array item shouldn't be changed!
- renameItem(oldname,newname):void
- changes the name of a array item
- note - the name is a special attribute of a item, it can't be changed direct!
- removeItem(name):*
- removes the item from the array
- and returns the removed item
here a example how to parse a array in AS3 in the fastest way:
(AS3 code)
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
|
var plugins:Object = krpano.get("plugin");
var pluginsarray:Array = plugins.getArray();
var count:int = pluginsarray.length;
var i:int;
for (i=0; i<count; i++)
{
var item:Object = pluginsarray[i];
trace(item.name);
}
|
I hope I could clarify some of the krpano internals to help using it
best regards,
Klaus