https://api.openfl.org/openfl/net/SharedObject.html#getLocal
https://github.com/openfl/openfl/blob/develop/src/openfl/net/SharedObject.hx
When accessing a local storage with getLocal() you can pass the storage name without path. In this case the function creates the object id in js and html5 by appending name to the browser href using “:” as a separator:
Browser.window.location.href + ":" + name
But if you pass name AND path, the function appends the name to the path using “/” as a separator, so if I want to access the previously created local save with preset path, I can’t do so because the names are different.
var id = localPath + "/" + name;
I can’t pass the full path as a name to getLocal either, because “:” is forbidden for the name:
var illegalValues = [" ", "~", "%", "&", "\\", ";", ":", "\"", "'", ",", "<", ">", "?", "#"];
So there is no way to access the object that was created with omitted path by using the existing full path, that I believe is incorrect. In my case, the portal stores game updates in separate folders, like 1, 2, 3 etc. so I want to copy the saved games from the objects that were created with omitted paths, like
/game_name/3/index.html:save_name
But I can’t
I could change it as desired by changing the way SharedObject appends name to path:
#if (js && html5)
var id = localPath + ":" + name;
#else
var id = localPath + "/" + name;
#end
But I don’t think I can suggest such a fix to the source code on GitHub, because some may relied on the current “/” delimiter previously and it will make objects created with path and name inaccessible.
A safer way would be to remove “:” from illegal values for name like this:
#if (js && html5)
var illegalValues = [" ", "~", "%", "&", "\\", ";", "\"", "'", ",", "<", ">", "?", "#"];
#else
var illegalValues = [" ", "~", "%", "&", "\\", ";", ":", "\"", "'", ",", "<", ">", "?", "#"];
#end
This sounds reasonable for me, because later the function uses illegal “:” to join path and name for HTML5/JS.
Then I will be able to access the object by passing “” as path and path_without_leading_slash+":"+name to getLocal. Like:
SharedObject.getLocal("game_name/3/index.html:save_name", "");
The function then will let the name with “:” to pass through and make a correct id after
var id = localPath + "/" + name;
But this sounds gimmicky IDK