Skip to content

Commit 5ea2c58

Browse files
committed
fix for issue mikechambers#182 on original fork.
1 parent 1cf569b commit 5ea2c58

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/com/adobe/serialization/json/JSONEncoder.as

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ package com.adobe.serialization.json
199199
*/
200200
private function arrayToString( a:Array ):String
201201
{
202+
// arrays of the __HTMLScriptArray type use string keys rather than numeric keys
203+
var typeName:String = describeType( a ).@name.toString();
204+
var isScriptArray:Boolean = (typeName == "flash.html::__HTMLScriptArray" || typeName == "flash.html::__HTMLScriptObject");
205+
202206
// create a string to store the array's jsonstring value
203207
var s:String = "";
204208

@@ -216,7 +220,7 @@ package com.adobe.serialization.json
216220
}
217221

218222
// convert the value to a string
219-
s += convertToString( a[ i ] );
223+
s += convertToString( a[ isScriptArray ? i.toString() : i ] );
220224
}
221225

222226
// KNOWN ISSUE: In ActionScript, Arrays can also be associative
@@ -252,7 +256,7 @@ package com.adobe.serialization.json
252256

253257
// determine if o is a class instance or a plain object
254258
var classInfo:XML = describeType( o );
255-
if ( classInfo.@name.toString() == "Object" )
259+
if ( classInfo.@name.toString() == "Object" || classInfo.@name.toString() == "flash.html::__HTMLScriptObject" )
256260
{
257261
// the value of o[key] in the loop below - store this
258262
// as a variable so we don't have to keep looking up o[key]

0 commit comments

Comments
 (0)