Problem
When a window is created with the *url* property, that url used to be (2.1.2 and earlier) treated as relative to the Resources directory. Now (2.2.0.v20120904164912) it is treated as relative to the directory of the calling js file. If the calling js file is in a subdirectory, an error (java.io.FileNotFoundException) is generated. This is going to break a lot of existing code.
Works in 2.1.2
Broken in 2.2.0.v20120904164912
Testcase
Note in this example that the "loader.js" file is in a "ui" subdirectory.
{panel:title=app.js}
Ti.UI.setBackgroundColor('#000');
Ti.include('ui/loader.js');
{panel}
{panel:title=ui/loader.js}
var win1=Ti.UI.createWindow({
title:'Window 1',
backgroundColor:'#fff',
url:'win1.js'
});
win1.open();
{panel}
{panel:title=win1.js}
var winOne = Ti.UI.currentWindow;
var label1 = Ti.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
winOne.add(label1);
{panel}
Error log
...
[ERROR][TiAssetHelper( 345)] Error while reading asset "Resources/ui/win1.js":
[ERROR][TiAssetHelper( 345)] java.io.FileNotFoundException: Resources/ui/win1.js
[ERROR][TiAssetHelper( 345)] at android.content.res.AssetManager.openAsset(Native Method)
[ERROR][TiAssetHelper( 345)] at android.content.res.AssetManager.open(AssetManager.java:313)
[ERROR][TiAssetHelper( 345)] at android.content.res.AssetManager.open(AssetManager.java:287)
[ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.util.KrollAssetHelper.readAsset(KrollAssetHelper.java:77)
[ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
[ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:140)
[ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:284)
[ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:166)
[ERROR][TiAssetHelper( 345)] at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR][TiAssetHelper( 345)] at android.os.Looper.loop(Looper.java:123)
[ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:108)
{panel}
Helpdesk ticket: [APP-983576](http://support.appcelerator.com/tickets/APP-983576)
PR submitted: https://github.com/appcelerator/titanium_mobile/pull/3057
Tested with 3.0.0.20121204144658 on Droid 1 2.2.3
Verified fixed with SDK 3.0.2.v20130124164131. Thanks!