It's quite simple:
fTargetFile:File = File.applicationDirectory.resolvePath("assets");
fRootFile:File = File.applicationDirectory.resolvePath("assets");
fTargetFile.addEventListener(Event.SELECT,onSelect)
fTargetFile.browseForOpen("test"); <-- here I open a file in "/assets/images/test.jpg"
function onSelect(e:Event):void
{
trace(fRootFile.getRelativePath(fTargetFile)); <-- this returns null
}
Every single "tutorial" in the web - along with Adobe's documentation - gracefully uses resolvePath to explicitly point to the file objects, thereby bypassing the actual use case. getRelativePath indeed works with resolvePath, but using resolvePath means I've already known where the file is located in the first place, rendering getRelativePath actually useless
tracing the nativePath property of both objects returns the correct path.
What I'm trying to do is letting the user choose a file within the "assets" directory. The file can be from any folder so long as they're under the "assets", and once user chooses a file, display the relative path from "assets" to the chosen file.
So, in the example above, I expect "images/test.jpg" to be returned, but it returns nothing
Do I have to do some wizardry before getRelativePath works?